diff options
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: |