Refactored model files
This commit is contained in:
52
techdb/flightslot/models/courses.py
Normal file
52
techdb/flightslot/models/courses.py
Normal 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}"
|
||||
|
||||
Reference in New Issue
Block a user