Improved class naming for admin

This commit is contained in:
2025-11-21 19:11:21 +01:00
parent 7ad09e21b7
commit cbdf49adfd

View File

@@ -1,6 +1,5 @@
from django.utils.translation import gettext_lazy as _
from django.db import models
from datetime import timedelta
from polymorphic.models import PolymorphicModel
@@ -78,8 +77,17 @@ class HourBuildingLegBase(PolymorphicModel):
)
time = models.DurationField(
null=False
null=False,
blank=False
)
# Change displayed name in the inline form
class Meta(PolymorphicModel.Meta):
verbose_name = "Flight Leg or Stop"
verbose_name_plural = "Flight Legs or Stops"
def __str__(self):
return f"Hour Building Leg"
class HourBuildingLegFlight(HourBuildingLegBase):
departure = models.CharField(
@@ -102,7 +110,7 @@ class HourBuildingLegFlight(HourBuildingLegBase):
)
# Change displayed name in the inline form
class Meta(PolymorphicModel.Meta):
class Meta(HourBuildingLegBase.Meta):
verbose_name = "Flight leg"
verbose_name_plural = "Flight legs"
@@ -110,8 +118,8 @@ class HourBuildingLegFlight(HourBuildingLegBase):
return f"{self.departure} -> {self.destination}"
def save(self, *args, **kwargs):
self.departure = self.departure.capitalize().strip()
self.destination = self.destination.capitalize().strip()
self.departure = self.departure.upper().strip()
self.destination = self.destination.upper().strip()
super().save(*args, **kwargs)
class HourBuildingLegStop(HourBuildingLegBase):
@@ -121,7 +129,7 @@ class HourBuildingLegStop(HourBuildingLegBase):
)
# Change displayed name in the inline form
class Meta(PolymorphicModel.Meta):
class Meta(HourBuildingLegBase.Meta):
verbose_name = "Stop"
verbose_name_plural = "Stops"