summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/forms.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 72877c2e2..5d98b9718 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -445,6 +445,8 @@ class QAOperationCR(IshtarForm):
if self.profil.parcel_mandatory:
self.fields['parcel'].required = True
self.fields.pop('town')
+ else:
+ self.fields.pop("parcel")
if not self.items:
return
@@ -456,10 +458,11 @@ class QAOperationCR(IshtarForm):
(site.pk, str(site))
for site in operation.archaeological_sites.all()
]
- self.fields['parcel'].choices += [('', '--')] + [
- (str(parcel.pk), u"{} - {}".format(parcel.short_label, parcel.town))
- for parcel in operation.parcels.all()
- ]
+ if self.profil.parcel_mandatory:
+ self.fields['parcel'].choices += [('', '--')] + [
+ (str(parcel.pk), u"{} - {}".format(parcel.short_label,
+ parcel.town))
+ for parcel in operation.parcels.all()]
def save(self, items):
operation = items[0]
@@ -473,7 +476,5 @@ class QAOperationCR(IshtarForm):
if self.profil.parcel_mandatory:
data["parcel_id"] = self.cleaned_data['parcel']
else:
- if self.cleaned_data.get('parcel', None):
- data["parcel_id"] = self.cleaned_data['parcel']
data["town_id"] = self.cleaned_data['town']
models.ContextRecord.objects.create(**data)