From f5fc6f23f5369df98fb0fdb061bfbac3c9662677 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 23 Sep 2019 14:43:48 +0200 Subject: Hide parcel field for UE QA - Add cultural atribution for sites --- archaeological_context_records/forms.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'archaeological_context_records/forms.py') 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) -- cgit v1.2.3