From 9430e8577cff4995c310f5675ea5d2a619554ccf Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 17 Sep 2024 11:10:30 +0200 Subject: ✨ Operations: remove form from the wizard to put in a specific form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_context_records/forms.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'archaeological_context_records/forms.py') diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index f4176b619..e5d34117c 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -578,6 +578,7 @@ class RecordRelationsForm(OpeRecordRelationsForm): "relation_type": models.RelationType, } ERROR_MISSING = _("You should select a context record and a relation type.") + ERROR_SAME = _("A context record cannot be related to himself.") right_record = forms.ChoiceField( label=_("Context record"), choices=[], required=False @@ -585,16 +586,9 @@ class RecordRelationsForm(OpeRecordRelationsForm): def __init__(self, *args, **kwargs): crs = None - if "data" in kwargs and "CONTEXT_RECORDS" in kwargs["data"]: + if "data" in kwargs and "CURRENT_ITEMS" in kwargs["data"]: kwargs["data"] = copy(kwargs["data"]) - crs = kwargs["data"].pop("CONTEXT_RECORDS") - # clean data if not "real" data - prefix_value = kwargs['prefix'] + '-relation_type' - if not [k for k in kwargs['data'].keys() - if k.startswith(prefix_value) and kwargs['data'][k]]: - kwargs.pop('data') - if 'files' in kwargs: - kwargs.pop('files') + crs = kwargs["data"].pop("CURRENT_ITEMS") initial = kwargs.get("initial", {}) if initial and initial.get("right_record", None): if initial["right_record"] not in [cr_id for cr_id, cr_lbl in crs]: @@ -613,9 +607,9 @@ class RecordRelationsForm(OpeRecordRelationsForm): RecordRelationsFormSet = formset_factory( RecordRelationsForm, can_delete=True, formset=RecordRelationsFormSetBase ) -RecordRelationsFormSet.form_label = _("Relations") -RecordRelationsFormSet.form_admin_name = _("Context record - 050 - Relations") -RecordRelationsFormSet.form_slug = "contextrecord-050-recordrelations" +RecordRelationsFormSet.form_label = _("Context records - Relations") +RecordRelationsFormSet.form_admin_name = _("Context record - Relations") +RecordRelationsFormSet.form_slug = "contextrecord-recordrelations" class QAOperationCR(IshtarForm): -- cgit v1.2.3