summaryrefslogtreecommitdiff
path: root/archaeological_operations/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-10-18 12:48:05 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2023-10-18 12:50:55 +0200
commit20a8009562b4d03b334469fbe2902386be3371f4 (patch)
tree339fb76b82e542887d21a123a53c23631c42c9f3 /archaeological_operations/forms.py
parent249b6c73e645674d8ca699be25a138bceacd477d (diff)
downloadIshtar-20a8009562b4d03b334469fbe2902386be3371f4.tar.bz2
Ishtar-20a8009562b4d03b334469fbe2902386be3371f4.zip
🐛 Custom forms: fix crash when removing fields already filtered
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r--archaeological_operations/forms.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 2104938c2..97a479505 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -594,17 +594,19 @@ class OperationSelect(GeoItemSelect):
SITE_KEYS = {"archaeological_sites": None}
def __init__(self, *args, **kwargs):
- super(OperationSelect, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
profile = get_current_profile()
if not profile.warehouse:
- self.fields.pop('documentation_deadline_before')
- self.fields.pop('documentation_deadline_after')
- self.fields.pop('documentation_received')
- self.fields.pop('finds_deadline_before')
- self.fields.pop('finds_deadline_after')
- self.fields.pop('finds_received')
+ self._remove_fields((
+ 'documentation_deadline_before',
+ 'documentation_deadline_after',
+ 'documentation_received',
+ 'finds_deadline_before',
+ 'finds_deadline_after',
+ 'finds_received',
+ ))
if not profile.underwater:
- self.fields.pop('drassm_code')
+ self._remove_fields(("drassm_code",))
if settings.ISHTAR_DPTS:
k = 'towns__numero_insee__startswith'
self.fields[k].choices = [
@@ -865,7 +867,7 @@ class OperationFormGeneral(CustomForm, ManageOldType):
for key in self.WAREHOUSE_FIELDS:
self.remove_field(key)
if not profile.underwater:
- self.fields.pop('drassm_code')
+ self._remove_fields(("drassm_code",))
if 'collaborator' in self.fields:
self.fields['collaborator'].widget.attrs['full-width'] = True
if towns and towns != -1:
@@ -939,7 +941,7 @@ class OperationFormModifGeneral(OperationFormGeneral):
def __init__(self, *args, **kwargs):
super(OperationFormModifGeneral, self).__init__(*args, **kwargs)
if not get_current_profile().files:
- self.fields.pop('associated_file')
+ self._remove_fields(("associated_file",))
fields = OrderedDict()
for idx, field in enumerate(list(self.fields.items())):
@@ -1269,15 +1271,17 @@ class SiteSelect(GeoItemSelect):
] + GeoItemSelect.TYPES
def __init__(self, *args, **kwargs):
- super(SiteSelect, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
if not get_current_profile().underwater:
- self.fields.pop('shipwreck_name')
- self.fields.pop('oceanographic_service_localisation')
- self.fields.pop('shipwreck_code')
- self.fields.pop('sinking_date')
- self.fields.pop('discovery_area')
- self.fields.pop('affmar_number')
- self.fields.pop('drassm_number')
+ self._remove_fields((
+ 'shipwreck_name',
+ 'oceanographic_service_localisation',
+ 'shipwreck_code',
+ 'sinking_date',
+ 'discovery_area',
+ 'affmar_number',
+ 'drassm_number',
+ ))
class SiteFormSelection(LockForm, CustomFormSearch):