diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-02 16:47:27 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-16 17:04:41 +0100 |
commit | a6bd637b8bf662d12d96609c018a4e6cb048ee2a (patch) | |
tree | 441a8724a7185f903f8d6fb25975e92a95392a5b | |
parent | 340c526e4a24598ec0bde0cf55a41f5a94d9e8c7 (diff) | |
download | Ishtar-a6bd637b8bf662d12d96609c018a4e6cb048ee2a.tar.bz2 Ishtar-a6bd637b8bf662d12d96609c018a4e6cb048ee2a.zip |
Context record: bulk update - change type
-rw-r--r-- | archaeological_context_records/forms.py | 13 |
1 files changed, 12 insertions, 1 deletions
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) |