Refactored model files

This commit is contained in:
2025-11-14 12:01:14 +01:00
parent ea33bef9cd
commit be25a07272
17 changed files with 601 additions and 318 deletions

View File

@@ -0,0 +1,52 @@
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")
OTHER = "OTHER",_("OTHER")
class Course(models.Model):
# Add colors according to table from Alessia
COLOR_PALETTE = [
("#ffffff","WHITE"),
("#ff0000", "RED"),
("#00ff00", "GREEN"),
("#0000ff", "BLUE")
]
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 (
samples=COLOR_PALETTE,
verbose_name=_("Binder Color")
)
def __str__(self):
return f"{self.ctype}-{self.cnumber}"