summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/forms.py16
-rw-r--r--archaeological_finds/models_treatments.py2
-rw-r--r--archaeological_finds/wizards.py20
3 files changed, 29 insertions, 9 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 663ab3663..4df6629e1 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -53,7 +53,8 @@ from bootstrap_datepicker.widgets import DatePicker
from ishtar_common import widgets
from ishtar_common.forms import CustomForm, CustomFormSearch, FormSet, \
FloatField, reverse_lazy, TableSelect, get_now, FinalForm, \
- ManageOldType, FieldType, IshtarForm, FormHeader, QAForm, HistorySelect
+ ManageOldType, FieldType, IshtarForm, FormHeader, QAForm, HistorySelect, \
+ PkWizardSearch
from ishtar_common.forms_common import get_town_field
from ishtar_common.models import valid_id, valid_ids, get_current_profile, \
SpatialReferenceSystem, Area, OperationType
@@ -910,8 +911,19 @@ class FindDeletionForm(FinalForm):
confirm_end_msg = _(u"Would you like to delete this find?")
-class UpstreamFindFormSelection(FindFormSelection):
+class UpstreamFindFormSelection(PkWizardSearch, FindFormSelection):
form_label = _(u"Upstream find")
+ current_model = models.Find
+ pk_key = 'resulting_pk'
+
+ pk = forms.CharField(
+ label="", required=False,
+ widget=widgets.DataTable(
+ reverse_lazy('get-find'),
+ FindSelect, current_model,
+ multiple_select=True,
+ source_full=reverse_lazy('get-find-full')),
+ validators=[valid_ids(current_model)])
def __init__(self, *args, **kwargs):
super(UpstreamFindFormSelection, self).__init__(*args, **kwargs)
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 61d4ce5be..160e9d32d 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -68,7 +68,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
"upstream_cached_label": _(u"Upstream find"),
"treatment_types__label": _(u"Type"),
"treatment_state__label": _(u"State"),
- 'person__cached_label': _(u"Responsible"),
+ "person__cached_label": _(u"Responsible"),
}
# extra keys than can be passed to save method
EXTRA_SAVED_KEYS = ('items', 'user')
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index e90fa745c..3314759d1 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -119,14 +119,17 @@ class TreatmentWizard(Wizard):
kwargs['user'] = self.request.user
return kwargs
- def get_current_find(self):
+ def get_current_finds(self):
step = self.steps.current
if not step:
return
find_form_key = 'selecfind-treatment_creation'
- find_id = self.session_get_value(find_form_key, "resulting_pk")
+ find_ids = self.session_get_value(find_form_key, "resulting_pk")
try:
- return models.Find.objects.get(pk=int(find_id))
+ return [
+ models.Find.objects.get(pk=int(find_id.strip()))
+ for find_id in find_ids.split(u',')
+ ]
except(TypeError, ValueError, ObjectDoesNotExist):
pass
@@ -134,12 +137,17 @@ class TreatmentWizard(Wizard):
initial = super(TreatmentWizard, self).get_form_initial(step)
if step != 'basetreatment-treatment_creation':
return initial
- find = self.get_current_find()
- if not find or not find.container:
+ finds = self.get_current_finds()
+ if not finds:
+ return initial
+ locations = [find.container.location.pk for find in finds
+ if find.container]
+ # no location or multiple locations
+ if not locations or len(set(locations)) != 1:
return initial
if not initial:
initial = {}
- initial['location'] = find.container.location.pk
+ initial['location'] = locations[0]
return initial
def get_extra_model(self, dct, form_list):