summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-21 23:53:23 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-21 23:53:23 +0100
commit9eacb3f2b2f5819ef3eea1a54bb2c4bfb13efda6 (patch)
tree2a2b687acef6f878c05f7148a150c10c3a7fb71a /archaeological_finds/forms.py
parent8eb09a666e7048ce8e531649566418670d94036d (diff)
parentc00bb6298a602f74c55cfd60b8601295470a8e3b (diff)
downloadIshtar-9eacb3f2b2f5819ef3eea1a54bb2c4bfb13efda6.tar.bz2
Ishtar-9eacb3f2b2f5819ef3eea1a54bb2c4bfb13efda6.zip
Merge branch 'master' into v0.9
Conflicts: Makefile.example archaeological_operations/migrations/0061_regenerate_cached_label.py archaeological_warehouse/migrations/0024_generate_cache_lbl_for_containers.py
Diffstat (limited to 'archaeological_finds/forms.py')
-rw-r--r--archaeological_finds/forms.py50
1 files changed, 46 insertions, 4 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 2c367043c..09d23a3bc 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -48,6 +48,8 @@ from ishtar_common.utils import convert_coordinates_to_point
from ishtar_common import widgets
from archaeological_operations.widgets import OAWidget
+from archaeological_warehouse.models import Warehouse
+
from archaeological_finds.forms_treatments import TreatmentSelect, \
TreatmentFormSelection, BaseTreatmentForm, TreatmentModifyForm, \
AdministrativeActTreatmentForm, TreatmentFormFileChoice, \
@@ -75,7 +77,8 @@ __all__ = [
'SourceTreatmentFileFormSelection', 'TreatmentSourceFormSelection',
'TreatmentFileSourceFormSelection',
'RecordFormSelection', 'FindForm', 'DateForm', 'DatingFormSet',
- 'FindSelect', 'FindFormSelection', 'MultipleFindFormSelection',
+ 'FindSelect', 'FindFormSelection', 'FindFormSelectionWarehouseModule',
+ 'MultipleFindFormSelection', 'MultipleFindFormSelectionWarehouseModule',
'FindMultipleFormSelection', 'check_form', 'check_exist', 'check_not_exist',
'check_value', 'check_type_field', 'check_type_not_field',
'check_treatment', 'ResultFindForm', 'ResultFindFormSet',
@@ -348,7 +351,6 @@ class FindSelect(TableSelect):
label=_(u"Search within related operations"), choices=[],
widget=widgets.CheckboxSelectMultiple)
datings__period = forms.ChoiceField(label=_(u"Period"), choices=[])
- # TODO search by warehouse
material_types = forms.ChoiceField(label=_(u"Material type"), choices=[])
object_types = forms.ChoiceField(label=_(u"Object type"), choices=[])
preservation_to_considers = forms.ChoiceField(
@@ -410,6 +412,23 @@ class FindSelect(TableSelect):
return ids
+class FindSelectWarehouseModule(FindSelect):
+ container__location = forms.IntegerField(
+ label=_(u"Warehouse (location)"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-warehouse'),
+ associated_model=Warehouse),
+ validators=[valid_id(Warehouse)])
+ container__responsible = forms.IntegerField(
+ label=_(u"Warehouse (responsible)"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-warehouse'),
+ associated_model=Warehouse),
+ validators=[valid_id(Warehouse)])
+ container__index = forms.IntegerField(label=_(u"Container ID"))
+ container__reference = forms.IntegerField(label=_(u"Container ref."))
+
+
class FindFormSelection(forms.Form):
form_label = _("Find search")
associated_models = {'pk': models.Find}
@@ -423,6 +442,16 @@ class FindFormSelection(forms.Form):
validators=[valid_id(models.Find)])
+class FindFormSelectionWarehouseModule(FindFormSelection):
+ pk = forms.IntegerField(
+ label="", required=False,
+ widget=widgets.JQueryJqGrid(
+ reverse_lazy('get-find'),
+ FindSelectWarehouseModule, models.Find,
+ source_full=reverse_lazy('get-find-full')),
+ validators=[valid_id(models.Find)])
+
+
class MultipleFindFormSelection(forms.Form):
form_label = _("Find search")
associated_models = {'pk': models.Find}
@@ -437,15 +466,28 @@ class MultipleFindFormSelection(forms.Form):
validators=[valid_id(models.Find)])
+class MultipleFindFormSelectionWarehouseModule(MultipleFindFormSelection):
+ pk = forms.IntegerField(
+ label="", required=False,
+ widget=widgets.JQueryJqGrid(
+ reverse_lazy('get-find'),
+ FindSelectWarehouseModule, models.Find,
+ multiple_select=True,
+ source_full=reverse_lazy('get-find-full')),
+ validators=[valid_id(models.Find)])
+
+
class FindMultipleFormSelection(forms.Form):
form_label = _(u"Upstream finds")
associated_models = {'finds': models.Find}
associated_labels = {'finds': _(u"Finds")}
+ # using FindSelectWarehouseModule because this form is only used with
+ # the warehouse module activated
finds = forms.CharField(
label="", required=False,
widget=widgets.JQueryJqGrid(
- reverse_lazy('get-find'), FindSelect, models.Find, multiple=True,
- multiple_cols=[2, 3, 4]),
+ reverse_lazy('get-find'), FindSelectWarehouseModule, models.Find,
+ multiple=True, multiple_cols=[2, 3, 4]),
validators=[valid_ids(models.Find)])
def clean(self):