summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/forms.py')
-rw-r--r--archaeological_finds/forms.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 727657fc2..fdb44d0ac 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -92,6 +92,10 @@ from ishtar_common.forms import (
GeoItemSelect,
)
from ishtar_common.forms_common import get_town_field
+from archaeological_operations.forms import (
+ RecordRelationsForm,
+ RecordRelationsFormSetBase,
+)
from archaeological_context_records.forms import DatingSelect
from ishtar_common.models import (
@@ -925,6 +929,32 @@ class ResultingFindsForm(CustomForm, ManageOldType):
return self.cleaned_data
+class FindRecordRelationsForm(RecordRelationsForm):
+ current_model = models.FindRelationType
+ current_related_model = models.Find
+ associated_models = {
+ "right_record": models.Find,
+ "relation_type": models.FindRelationType,
+ }
+ ERROR_MISSING = _("You should select a find and a relation type.")
+ ERROR_SAME = _("A find cannot be related to himself.")
+
+ right_record = forms.IntegerField(
+ label=_("Find"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-find'),
+ associated_model=models.Find),
+ validators=[valid_id(models.Find)], required=False)
+
+
+FindRecordRelationsFormSet = formset_factory(
+ FindRecordRelationsForm, can_delete=True, formset=RecordRelationsFormSetBase
+)
+FindRecordRelationsFormSet.form_label = _("Find - Relations")
+FindRecordRelationsFormSet.form_admin_name = _("Find - Relations")
+FindRecordRelationsFormSet.form_slug = "find-recordrelations"
+
+
class QAFindFormMulti(MuseumForm, QAForm):
form_admin_name = _("Find - Quick action - Modify")
form_slug = "find-quickaction-modify"