First version of flight preference forms
This commit is contained in:
134
techdb/flightslot/models.py
Normal file
134
techdb/flightslot/models.py
Normal file
@@ -0,0 +1,134 @@
|
||||
from django.db import models
|
||||
from django.contrib import admin
|
||||
from django.db.models.functions import Now, ExtractWeek
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
# Create your models here.
|
||||
class StudentAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "surname", "email")
|
||||
list_filter = []
|
||||
|
||||
class Student(models.Model):
|
||||
id = models.AutoField(
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
email = models.EmailField(
|
||||
null=False,
|
||||
db_index=True
|
||||
)
|
||||
|
||||
name = models.CharField(
|
||||
null=False,
|
||||
max_length=32
|
||||
)
|
||||
|
||||
surname = models.CharField(
|
||||
null=False,
|
||||
max_length=32
|
||||
)
|
||||
|
||||
|
||||
class MissionType(models.TextChoices):
|
||||
OTHER = "OTHER", _("OTHER")
|
||||
HB = "HB", _("HB")
|
||||
PPL = "PPL", _("PPL")
|
||||
IR = "IR", _("IR")
|
||||
CPL = "CPL", _("CPL")
|
||||
FI = "FI", _("FI")
|
||||
PC = "PC", _("PC")
|
||||
CHK = "CHK", _("CHK_6M")
|
||||
|
||||
class MissionProfile(models.Model):
|
||||
|
||||
id = models.AutoField(
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
mtype = models.CharField(
|
||||
null=False,
|
||||
default=MissionType.HB,
|
||||
choices=MissionType
|
||||
)
|
||||
|
||||
mnum = models.PositiveSmallIntegerField(
|
||||
null=True,
|
||||
default=0
|
||||
)
|
||||
|
||||
duration = models.DurationField(
|
||||
null=False
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
if self.mtype is not MissionType.HB:
|
||||
return f"{self.mtype}_{self.mnum}"
|
||||
|
||||
class MissionProfileAdmin(admin.ModelAdmin):
|
||||
list_display = ("mtype", "mnum")
|
||||
|
||||
class WeekPreference(models.Model):
|
||||
id = models.BigAutoField(
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
week = models.PositiveSmallIntegerField(
|
||||
null=False,
|
||||
db_index=True,
|
||||
db_default=ExtractWeek(Now()) + 1
|
||||
)
|
||||
|
||||
student = models.ForeignKey(
|
||||
Student,
|
||||
null=False,
|
||||
db_index=True,
|
||||
on_delete=models.DO_NOTHING
|
||||
)
|
||||
|
||||
|
||||
class Preference(models.Model):
|
||||
id = models.BigAutoField(
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
weekpref = models.ForeignKey(
|
||||
WeekPreference,
|
||||
null=False,
|
||||
on_delete=models.DO_NOTHING
|
||||
)
|
||||
|
||||
mission = models.ForeignKey(
|
||||
MissionProfile,
|
||||
null=True,
|
||||
on_delete=models.DO_NOTHING
|
||||
)
|
||||
|
||||
monday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
tuesday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
wednesday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
thursday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
saturday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
sunday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
Reference in New Issue
Block a user