Skip to content
Snippets Groups Projects
models.py 814 B
Newer Older
from django.db import models

# Create your models here.
from aleksis.core.mixins import ExtensibleModel
from aleksis.core.util.core_helpers import path_and_rename
from django.utils.translation import gettext_lazy as _
def path_and_rename_menu(instance, filename: str) -> str:
    return path_and_rename(instance, filename, upload_to="menu")


class Menu(ExtensibleModel):
    calendar_week = models.IntegerField(verbose_name=_("CW"))
    year = models.IntegerField(verbose_name=_("Year"))
    pdf = models.FileField(upload_to=path_and_rename_menu, verbose_name=_("PDF"))

    class Meta:
        unique_together = ("calendar_week", "year")
        verbose_name = _("Menu")
        verbose_name_plural = _("Menus")

    def __str__(self):
        return "{} {}/{}".format(_("CW"), self.calendar_week, self.year)