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.py64
1 files changed, 55 insertions, 9 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 2c367043c..8fe945e88 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',
@@ -144,18 +147,22 @@ class FindForm(ManageOldType, forms.Form):
required=False)
is_complete = forms.NullBooleanField(label=_(u"Is complete?"),
required=False)
- material_type = widgets.MultipleAutocompleteField(
- model=models.MaterialType, label=_(u"Material type"), required=False)
+ material_type = widgets.Select2MultipleField(
+ model=models.MaterialType, label=_(u"Material type"), required=False,
+ available=True
+ )
conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"),
choices=[], required=False)
conservatory_comment = forms.CharField(
label=_(u"Conservatory comment"), required=False,
widget=forms.Textarea)
- object_type = widgets.MultipleAutocompleteField(
- model=models.ObjectType, label=_(u"Object types"), required=False)
+ object_type = widgets.Select2MultipleField(
+ model=models.ObjectType, label=_(u"Object types"), required=False,
+ available=True
+ )
preservation_to_consider = forms.MultipleChoiceField(
label=_(u"Preservation type"), choices=[],
- widget=widgets.CheckboxSelectMultiple, required=False)
+ widget=widgets.Select2Multiple, required=False)
integritie = forms.MultipleChoiceField(
label=_(u"Integrity / interest"), choices=[],
widget=widgets.CheckboxSelectMultiple, required=False)
@@ -348,7 +355,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 +416,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 +446,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 +470,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):