From 98ed6a871b21d8f80af5d386a1b59288bd862830 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 2 Nov 2021 16:47:27 +0100 Subject: Context record: bulk update - change type --- archaeological_context_records/forms.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index 594ed1346..157da64e1 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -695,10 +695,13 @@ class QAContextRecordFormMulti(QAForm): form_admin_name = _("Context record - Quick action - Modify") form_slug = "contextrecord-quickaction-modify" - base_models = ["qa_relation_type"] + base_models = ["qa_relation_type", "qa_related_to", "qa_unit"] associated_models = { "qa_relation_type": models.RelationType, + "qa_related_to": models.ContextRecord, + "qa_unit": models.Unit, } + REPLACE_FIELDS = ["qa_unit"] MULTI = True qa_relation_type = forms.ChoiceField( @@ -714,9 +717,11 @@ class QAContextRecordFormMulti(QAForm): validators=[valid_id(models.ContextRecord)], required=False, ) + qa_unit = forms.ChoiceField(label=_("Unit type"), choices=[], required=False) TYPES = [ FieldType("qa_relation_type", models.RelationType), + FieldType("qa_unit", models.Unit), ] def clean(self): @@ -730,6 +735,12 @@ class QAContextRecordFormMulti(QAForm): ) ) + def _get_qa_related_to(self, value): + try: + return str(models.ContextRecord.objects.get(pk=value)) + except models.ContextRecord.DoesNotExist: + return "" + def _set_qa_related_to(self, item, __): r_type = self.cleaned_data.get("qa_relation_type", None) r_related = self.cleaned_data.get("qa_related_to", None) -- cgit v1.2.3