From cbdf49adfd5ce1458147c8e7d9a56030c5ab9af1 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Fri, 21 Nov 2025 19:11:21 +0100 Subject: [PATCH] Improved class naming for admin --- cntmanage/flightslot/models/hourbuildings.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cntmanage/flightslot/models/hourbuildings.py b/cntmanage/flightslot/models/hourbuildings.py index cc1b60f..e9e1e5b 100644 --- a/cntmanage/flightslot/models/hourbuildings.py +++ b/cntmanage/flightslot/models/hourbuildings.py @@ -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"