Refactored model files
This commit is contained in:
103
techdb/flightslot/models/hourbuildings.py
Normal file
103
techdb/flightslot/models/hourbuildings.py
Normal file
@@ -0,0 +1,103 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.db import models
|
||||
from datetime import timedelta
|
||||
|
||||
from ..models.weekpref import WeekPreference
|
||||
from ..models.aircrafts import AircraftTypes
|
||||
|
||||
|
||||
class HourBuilding(models.Model):
|
||||
id = models.BigAutoField(
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
weekpref = models.ForeignKey(
|
||||
WeekPreference,
|
||||
null=False,
|
||||
on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
aircraft = models.CharField(
|
||||
null=False,
|
||||
choices=AircraftTypes
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
friday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
saturday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
sunday = models.BooleanField(
|
||||
default=True,
|
||||
null=False
|
||||
)
|
||||
|
||||
notes = models.TextField(
|
||||
max_length=140,
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
|
||||
class HourBuildingLeg(models.Model):
|
||||
id = models.BigAutoField(
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
hb = models.ForeignKey(
|
||||
HourBuilding,
|
||||
on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
departure = models.CharField(
|
||||
null=False,
|
||||
blank=False,
|
||||
default="LILV",
|
||||
max_length=4
|
||||
)
|
||||
|
||||
destination = models.CharField(
|
||||
null=False,
|
||||
blank=False,
|
||||
default="LILV",
|
||||
max_length=4
|
||||
)
|
||||
|
||||
time = models.DurationField(
|
||||
null=False,
|
||||
default = timedelta(hours=1)
|
||||
)
|
||||
|
||||
stop = models.BooleanField(
|
||||
default=False
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
if self.stop:
|
||||
return "Refuelling Stop"
|
||||
else:
|
||||
return f"Flight Leg: {self.departure} -> {self.destination}"
|
||||
Reference in New Issue
Block a user