diff options
Diffstat (limited to 'archaeological_files/models.py')
-rw-r--r-- | archaeological_files/models.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 334e8faa4..ab84be8cb 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -104,15 +104,6 @@ class EquipmentServiceType(GeneralType): generic_equipment_type = models.ForeignKey( GenericEquipmentServiceType, verbose_name=_("Generic type")) order = models.IntegerField(_("Order"), default=10) - parent = models.ForeignKey( - "self", - blank=True, - null=True, - on_delete=models.CASCADE, - verbose_name=_("Parent"), - help_text=_("Auto-add this cost when a parent is added"), - related_name="children" - ) class Meta: verbose_name = _("Equipment/service type") @@ -131,6 +122,16 @@ ES_UNITS = ( class EquipmentServiceCost(models.Model): equipment_service_type = models.ForeignKey( EquipmentServiceType, verbose_name=_("Equipment/Service")) + slug = models.SlugField( + _("Textual ID"), + unique=True, + max_length=300, + help_text=_( + "The slug is the standardized version of the name. It contains " + "only lowercase letters, numbers and hyphens. Each slug must " + "be unique." + ), + ) service_provider = models.CharField( _("Service provider"), max_length=200, blank=True, default="") flat_rate = models.BooleanField(_("Flat rate"), default=False) @@ -141,6 +142,15 @@ class EquipmentServiceCost(models.Model): max_length=200, default="") order = models.IntegerField(_("Order"), default=10) available = models.BooleanField(_("Available"), default=True) + parent = models.ForeignKey( + EquipmentServiceType, + blank=True, + null=True, + on_delete=models.CASCADE, + verbose_name=_("Parent"), + help_text=_("Auto-add this cost when a parent is added"), + related_name="children" + ) class Meta: verbose_name = _("Equipment/service cost") @@ -148,7 +158,10 @@ class EquipmentServiceCost(models.Model): ordering = ("order", "equipment_service_type__label",) def __str__(self): - lbl = str(self.equipment_service_type) + lbl = "" + if self.parent: + lbl = self.parent.label + " - " + lbl += str(self.equipment_service_type) if self.specificity: lbl += " - " + self.specificity if self.service_provider: |