diff options
Diffstat (limited to 'archaeological_files/models.py')
-rw-r--r-- | archaeological_files/models.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 47e6185ca..b45589509 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -125,12 +125,16 @@ class Job(GeneralType): ) ADMIN_SECTION = _("Preventive") - def __str__(self): + @property + def display_label(self): lbl = self.label if not self.permanent_contract: lbl += " ({})".format(_("fixed-term contract")) return lbl + def __str__(self): + return self.display_label + f" - {self.price_agreement}" + @property def has_parents(self): return bool(self.parents.count()) @@ -143,14 +147,17 @@ class Job(GeneralType): ) if price_agreement_id: q = q.filter(price_agreement=price_agreement_id) - permanent = [(j.pk, str(j)) for j in q.filter(permanent_contract=True).all()] - fixed_term = [(j.pk, str(j)) for j in q.filter(permanent_contract=False).all()] - if current_value: - if current_value.permanent_contract: - permanent.append((current_value.pk, str(current_value))) - else: - fixed_term.append((current_value.pk, str(current_value))) - return [("", "-" * 9)] + [ + permanent = [ + (j.pk, j.display_label) for j in q.filter(permanent_contract=True).all() + ] + fixed_term = [ + (j.pk, j.display_label) for j in q.filter(permanent_contract=False).all() + ] + choices = [("", "-" * 9)] + if current_value and \ + current_value.pk not in [pk for pk, __ in (permanent + fixed_term)]: + choices.append((current_value.pk, str(current_value))) + choices += [ ( _("Permanent contract"), permanent, @@ -160,6 +167,7 @@ class Job(GeneralType): fixed_term, ), ] + return choices class GenericEquipmentServiceType(GeneralType): @@ -266,7 +274,7 @@ class EquipmentServiceCost(models.Model): Used for automatic documentation generation """ s = [] - exclude = ["id", "order", "availabel"] + exclude = ["id", "order", "available"] for field in cls._meta.get_fields(): if field.name in exclude: continue @@ -275,6 +283,13 @@ class EquipmentServiceCost(models.Model): s = ", ".join(s) return s + @property + def display_label(self): + lbl = str(self.equipment_service_type) + if self.specificity: + lbl += " - " + self.specificity + return lbl + def __str__(self): lbl = "" if self.parent: |