Nested polymorphic hour building legs and stops added, needs restyling
This commit is contained in:
@@ -2,10 +2,11 @@ from django.utils.translation import gettext_lazy as _
|
||||
from django.db import models
|
||||
from datetime import timedelta
|
||||
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
from ..models.weekpref import WeekPreference
|
||||
from ..models.aircrafts import AircraftTypes
|
||||
|
||||
|
||||
class HourBuilding(models.Model):
|
||||
id = models.BigAutoField(
|
||||
primary_key=True
|
||||
@@ -66,7 +67,7 @@ class HourBuilding(models.Model):
|
||||
def __str__(self):
|
||||
return f"Hour Building: {self.aircraft}"
|
||||
|
||||
class HourBuildingLeg(models.Model):
|
||||
class HourBuildingLegBase(PolymorphicModel):
|
||||
id = models.BigAutoField(
|
||||
primary_key=True
|
||||
)
|
||||
@@ -76,6 +77,12 @@ class HourBuildingLeg(models.Model):
|
||||
on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
time = models.DurationField(
|
||||
null=False,
|
||||
default = timedelta(hours=1)
|
||||
)
|
||||
|
||||
class HourBuildingLegFlight(HourBuildingLegBase):
|
||||
departure = models.CharField(
|
||||
null=False,
|
||||
blank=False,
|
||||
@@ -90,18 +97,17 @@ class HourBuildingLeg(models.Model):
|
||||
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}"
|
||||
|
||||
return f"Flight Leg: {self.departure} -> {self.destination}"
|
||||
|
||||
class HourBuildingLegStop(HourBuildingLegBase):
|
||||
location = models.CharField(
|
||||
null=False,
|
||||
blank=False,
|
||||
default="LILV",
|
||||
max_length=4
|
||||
)
|
||||
|
||||
refuel = models.BooleanField(
|
||||
default=False
|
||||
)
|
||||
Reference in New Issue
Block a user