Adde Aircraft class and associate students with aircrafts

This commit is contained in:
2025-11-28 10:16:01 +01:00
parent 33c610dcbc
commit de39913275
11 changed files with 190 additions and 67 deletions

View File

@@ -5,5 +5,45 @@ class AircraftTypes(models.TextChoices):
C152 = "C152", _("Cessna 152")
P208 = "P208", _("Tecnam P2008")
PA28 = "PA28", _("Piper PA28R")
PA34 = "PA34", _("Piper PA34")
C182 = "C182", _("Cessna 182Q")
P210 = "TWEN", _("Tecnam P2010")
ALX40 = "FSTD", _("Alsim ALX40")
class Aircraft(models.Model):
id = models.AutoField(
primary_key=True
)
type = models.CharField(
null=False,
blank=False,
max_length=4, # ICAO naming of aircraft,
choices=AircraftTypes
)
markings = models.CharField(
null=False,
blank=False,
max_length=6
)
complex = models.BooleanField(
null=False,
default=False
)
avail_hours = models.DurationField(
null=True,
verbose_name=_("Time until maintenance")
)
def __str__(self) -> str:
return f"{self.type} ({self.markings})"
# Insert dash between first and rest, I-OASM
def save(self, *args, **kwargs):
self.markings = self.markings.upper()
if not "-" in self.markings:
self.markings = self.markings[0] + "-" + self.markings[1:]
super().save(*args, **kwargs)