summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorCefin <kevon@tuta.io>2022-03-10 10:25:43 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-08 09:58:49 +0200
commit99d780b60fede4257d25d58d020651f47e1632af (patch)
tree28a373f544fb335f95a22f5844eb218f7d76648a /archaeological_context_records
parent8b9f5a964a63a201abd81dd6e4fa6a7320830241 (diff)
downloadIshtar-99d780b60fede4257d25d58d020651f47e1632af.tar.bz2
Ishtar-99d780b60fede4257d25d58d020651f47e1632af.zip
Context Record, Bulk update : link to parcels #5293
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/forms.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index f4c20d55a..44d89fcf1 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -702,6 +702,7 @@ class QAContextRecordFormMulti(QAForm):
"qa_related_to": models.ContextRecord,
"qa_unit": models.Unit,
"qa_town": models.Town,
+ "qa_parcel": models.Parcel,
}
REPLACE_FIELDS = [
"qa_unit",
@@ -739,12 +740,36 @@ class QAContextRecordFormMulti(QAForm):
),
required=False
)
+ qa_parcel = forms.ChoiceField(
+ label=_("Associated parcel"), choices=[], required=False
+ )
+ # qa_parcel.choices += [
+ # (p.pk, str(p)) for p in Parcel.objects.all()
+ # ]
TYPES = [
FieldType("qa_relation_type", models.RelationType),
FieldType("qa_unit", models.Unit),
]
+ def __init__(self, *args, **kwargs):
+ super(QAContextRecordFormMulti, self).__init__(*args, **kwargs)
+ self.items = kwargs.pop("items")
+ op_pk = 0
+ disable = False
+ for cr in self.items:
+ if op_pk != cr.operation.pk and op_pk > 0:
+ disable = self.fields["qa_parcel"].disabled = True
+ break
+ op_pk = cr.operation.pk
+ if not disable:
+ self.fields["qa_parcel"].choices += [
+ (p.pk, str(p)) for p in Parcel.objects.filter(
+ operation=self.items[-1].operation.pk
+ ).all()
+ ]
+
+
def clean(self):
cleaned_data = super().clean()
r_type = cleaned_data.get("qa_relation_type")