summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/forms.py12
-rw-r--r--archaeological_operations/views.py1
2 files changed, 8 insertions, 5 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index cf9df8594..d3c797ff2 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -371,10 +371,13 @@ class ParcelFormSet(FormSet):
class RecordRelationsForm(ManageOldType):
base_model = 'right_relation'
+ ERROR_MISSING = _("You should select an operation.")
current_model = models.RelationType
current_related_model = models.Operation
+
associated_models = {'right_record': models.Operation,
'relation_type': models.RelationType}
+ pk = forms.IntegerField(required=False, widget=forms.HiddenInput)
relation_type = forms.ChoiceField(label=_("Relation type"),
choices=[], required=False)
right_record = forms.IntegerField(
@@ -388,9 +391,9 @@ class RecordRelationsForm(ManageOldType):
self.left_record = None
if 'left_record' in kwargs:
self.left_record = kwargs.pop('left_record')
- super(RecordRelationsForm, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
self.fields['relation_type'].choices = \
- models.RelationType.get_types(
+ self.current_model.get_types(
initial=self.init_data.get('relation_type'))
@classmethod
@@ -409,7 +412,7 @@ class RecordRelationsForm(ManageOldType):
cleaned_data = self.cleaned_data
if (cleaned_data.get('relation_type', None) and
not cleaned_data.get('right_record', None)):
- raise forms.ValidationError(_("You should select an operation."))
+ raise forms.ValidationError(self.ERROR_MISSING)
if (not cleaned_data.get('relation_type', None) and
cleaned_data.get('right_record', None)):
raise forms.ValidationError(
@@ -455,6 +458,7 @@ class RecordRelationsForm(ManageOldType):
class RecordRelationsFormSetBase(FormSet):
+ delete_widget = forms.CheckboxInput
# passing left_record should be nicely done with form_kwargs with Django 1.9
# with no need of all these complications
@@ -462,7 +466,7 @@ class RecordRelationsFormSetBase(FormSet):
self.left_record = None
if 'left_record' in kwargs:
self.left_record = kwargs.pop('left_record')
- super(RecordRelationsFormSetBase, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def _construct_forms(self):
# instantiate all the forms and put them in self.forms
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 08a1ee05c..028f311e6 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -495,7 +495,6 @@ def get_parcel_modify(model, key_for_parcel, url_name):
return _modify_parcels
-
operation_modify_parcels = get_parcel_modify(
models.Operation, "operation", "operation-parcels-modify"
)