57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
from django.db import models
|
|
from datetime import date
|
|
from colorfield.fields import ColorField
|
|
|
|
class CourseTypes(models.TextChoices):
|
|
FI = "FI", _("FI")
|
|
PPL = "PPL", _("PPL")
|
|
ATPL = "ATPL", _("ATPL")
|
|
DISTANCE = "DL", _("DISTANCE")
|
|
DISTANCE_VOLO = "DL_VOLO", _("DISTANCE_VOLO")
|
|
OTHER = "OTHER",_("OTHER")
|
|
|
|
class Course(models.Model):
|
|
# Add colors according to table from Alessia
|
|
COLOR_PALETTE = [
|
|
("#bfbfbf","GREY"),
|
|
("#ff0000", "RED"),
|
|
("#ffc000", "ORANGE"),
|
|
("#ffff00", "YELLOW"),
|
|
("#92d050", "GREEN"),
|
|
("#00b0f0", "CYAN"),
|
|
("#b1a0c7", "MAGENTA"),
|
|
("#fabcfb", "PINK"),
|
|
("#f27ae4", "VIOLET"),
|
|
]
|
|
|
|
id = models.AutoField(
|
|
primary_key=True
|
|
)
|
|
|
|
ctype = models.CharField(
|
|
null=False,
|
|
choices=CourseTypes,
|
|
verbose_name=_("Course Type")
|
|
)
|
|
|
|
cnumber = models.PositiveSmallIntegerField(
|
|
null=False,
|
|
default=date.today().year,
|
|
verbose_name=_("Course Number")
|
|
)
|
|
|
|
year = models.PositiveSmallIntegerField(
|
|
null=False,
|
|
default=date.today().year,
|
|
verbose_name=_("Year")
|
|
)
|
|
|
|
color = ColorField (
|
|
verbose_name=_("Binder Color"),
|
|
samples=COLOR_PALETTE
|
|
)
|
|
|
|
def __str__(self):
|
|
return f"{self.ctype}-{self.cnumber}"
|
|
|