diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-06-13 12:50:39 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-06-13 12:50:39 +0200 |
commit | 87b95ae2f964f70993c490662017b227f0bef792 (patch) | |
tree | 780e7ef58503aa5b9fc8cf75d3d9e83c867b8935 /archaeological_operations/forms.py | |
parent | eb030fbecd62326b61e8669c34dbae9cb4770cfe (diff) | |
download | Ishtar-87b95ae2f964f70993c490662017b227f0bef792.tar.bz2 Ishtar-87b95ae2f964f70993c490662017b227f0bef792.zip |
🐛 operation/context record forms: filter site fields (refs #5873, #5874)
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r-- | archaeological_operations/forms.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 6b0959a91..af3c4bb3d 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -872,7 +872,7 @@ class OperationFormGeneral(CustomForm, ManageOldType): towns = None if kwargs.get("data", None) and kwargs['data'].get("TOWNS", None): towns = kwargs['data']['TOWNS'] - super(OperationFormGeneral, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) profile = get_current_profile() if not profile.files: for key in self.FILE_FIELDS: @@ -882,6 +882,10 @@ class OperationFormGeneral(CustomForm, ManageOldType): self.remove_field(key) if not profile.underwater: self._remove_fields(("drassm_code",)) + data = kwargs.get("data", {}) or kwargs.get("initial", {}) + has_site = any(1 for k, v in data.items() if v and k.split("-")[-1] == "archaeological_site") + if not has_site and not profile.archaeological_site: + self._remove_fields(("archaeological_site",)) if 'collaborator' in self.fields: self.fields['collaborator'].widget.attrs['full-width'] = True if towns and towns != -1: |