summaryrefslogtreecommitdiff
path: root/archaeological_context_records/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/forms.py')
-rw-r--r--archaeological_context_records/forms.py18
1 files changed, 6 insertions, 12 deletions
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):