diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-13 16:07:27 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-13 16:07:27 +0200 |
commit | ce93fcf5f31ef782652b1c2f59681b463808a5f6 (patch) | |
tree | dd8748baf6d7867ba222ad6698ec3fbfd028a9ca | |
parent | 8be1171a9cf90f5dd24a558baf718a0765d6a076 (diff) | |
download | Ishtar-ce93fcf5f31ef782652b1c2f59681b463808a5f6.tar.bz2 Ishtar-ce93fcf5f31ef782652b1c2f59681b463808a5f6.zip |
🐛 forms headers: manage header with conditionnal fields - find bulk update fix header (refs #6352)
-rw-r--r-- | archaeological_finds/forms.py | 3 | ||||
-rw-r--r-- | ishtar_common/forms.py | 15 |
2 files changed, 14 insertions, 4 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 65ca5aa66..332936d99 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -1009,7 +1009,8 @@ class QAFindFormMulti(MuseumForm, QAForm): HEADERS = { "qa_ue": FormHeader(_("Context record")), - "qa_denomination": FormHeader(_("Identification")), + "qa_label": FormHeader(_("Identification"), slug='identification'), + "qa_denomination": FormHeader(_("Identification"), slug='identification'), "qa_description": FormHeader(_("Description")), "qa_checked_type": FormHeader(_("Sheet")), "qa_period": FormHeader(_("Datation")), diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 20849c400..b14373df1 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -616,9 +616,10 @@ class FieldType(object): return self.model.get_help(**args) -class FormHeader(object): - def __init__(self, label, level=4, collapse=False, help_message=""): +class FormHeader: + def __init__(self, label, level=4, collapse=False, help_message="", slug=""): self.label = label + self.slug = slug or slugify(label) self.collapse = collapse self.level = level self.help_message = help_message @@ -745,7 +746,15 @@ class IshtarForm(forms.Form, BSForm): def get_headers(self): if self._headers: return self._headers - return self.HEADERS + self._headers = self.HEADERS + # if key is not available or header already used remove it + used = [] + for k in self._headers.keys(): + if k not in self.fields or self._headers[k].slug in used: + self._headers.pop(k) + continue + used.append(self._headers[k].slug) + return self._headers def headers(self, key): headers = self.get_headers() |