From 4e6d13e817d2389d5bb9b2a7848b6e9705e28912 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 11 Sep 2024 19:05:37 +0200 Subject: 🐛 sheet find: fix display for simple treatment with no container associated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_finds/models_finds.py | 6 ++++-- archaeological_finds/templates/ishtar/sheet_find.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index a5ff20773..53a1e3eef 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -3658,13 +3658,14 @@ class FindTreatment(models.Model): db_table = 'archaeological_finds_find_treatments' def location_type_label(self): - return LOCATION_TYPE_DICT[self.location_type] + if self.location_type in LOCATION_TYPE_DICT: + return LOCATION_TYPE_DICT[self.location_type] def generate_full_location(self): if getattr(self, "_full_location_set", False) or self.full_location or ( not self.treatment.is_current_container_changer and not self.treatment.is_reference_container_changer): - return + return False if self.treatment.is_current_container_changer: if self.treatment.is_reference_container_changer: self.location_type = "B" @@ -3678,6 +3679,7 @@ class FindTreatment(models.Model): self.full_location = self.container_ref.generate_full_location() self._full_location_set = True self.save() + return True class Property(LightHistorizedItem): diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 371888317..a3ecbdc67 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -403,7 +403,7 @@ {{ treatment.treatment_state|default_if_none:"-" }} {% for it in items %}{{it}} {{it|link_to_window:request}}{% endfor %} {{ treatment.person|default_if_none:"-" }} - {% if can_view_container %}{% for find_treatment in treatment.get_find_treatment_list %}{% if find_treatment.find.pk == item.pk %}{{ find_treatment.full_location|default_if_none:"-" }} {{find_treatment.location_type_label}}{% endif %}{% endfor %}{% endif %} + {% if can_view_container %}{% for find_treatment in treatment.get_find_treatment_list %}{% if find_treatment.find.pk == item.pk %}{{ find_treatment.full_location|default_if_none:"-" }}{% if find_treatment.location_type_label %} {{find_treatment.location_type_label}}{% endif %}{% endif %}{% endfor %}{% endif %} {{ treatment.start_date|default_if_none:"-" }}{% if treatment.end_date %}/{{ treatment.end_date|default_if_none:"-" }}{% endif %} {% endfor %} -- cgit v1.2.3