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.py53
1 files changed, 48 insertions, 5 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 9a52882b2..a617c8ee1 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -29,14 +29,16 @@ from django.forms.formsets import formset_factory
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
-from ishtar_common.models import Person, valid_id, valid_ids
-from archaeological_operations.models import Period, ArchaeologicalSite
+from ishtar_common.models import Person, valid_id, valid_ids, get_current_profile
+from archaeological_operations.models import Period, ArchaeologicalSite, \
+ RelationType as OpeRelationType
from archaeological_context_records.models import DatingType, DatingQuality, \
ContextRecord
from archaeological_warehouse.models import Warehouse
import models
from ishtar_common import widgets
+from archaeological_operations.widgets import OAWidget
from ishtar_common.forms import FormSet, FloatField, \
get_form_selection, reverse_lazy, TableSelect, get_now, FinalForm
from ishtar_common.forms_common import get_town_field, SourceSelect
@@ -78,12 +80,14 @@ class FindForm(forms.Form):
file_upload = True
form_label = _("Find")
base_models = ['get_first_base_find', 'object_type', 'material_type',
- 'preservation_to_consider', 'integritie']
+ 'preservation_to_consider', 'integritie',
+ 'remarkabilitie']
associated_models = {'material_type': models.MaterialType,
'conservatory_state': models.ConservatoryState,
'object_type': models.ObjectType,
'preservation_to_consider': models.PreservationType,
- 'integritie': models.IntegrityType}
+ 'integritie': models.IntegrityType,
+ 'remarkabilitie': models.RemarkabilityType}
label = forms.CharField(
label=_(u"Free ID"),
validators=[validators.MaxLengthValidator(60)])
@@ -110,6 +114,9 @@ class FindForm(forms.Form):
integritie = forms.MultipleChoiceField(
label=_(u"Integrity"), choices=[],
widget=forms.CheckboxSelectMultiple, required=False)
+ remarkabilitie = forms.MultipleChoiceField(
+ label=_(u"Remarkability"), choices=[],
+ widget=forms.CheckboxSelectMultiple, required=False)
length = FloatField(label=_(u"Length (cm)"), required=False)
width = FloatField(label=_(u"Width (cm)"), required=False)
height = FloatField(label=_(u"Height (cm)"), required=False)
@@ -127,6 +134,7 @@ class FindForm(forms.Form):
widget=forms.Textarea)
dating_comment = forms.CharField(
label=_(u"Comment on dating"), required=False, widget=forms.Textarea)
+ estimated_value = FloatField(label=_(u"Estimated value"), required=False)
image = forms.ImageField(
label=_(u"Image"), help_text=mark_safe(
_(u"<p>Heavy images are resized to: %(width)dx%(height)d "
@@ -152,6 +160,13 @@ class FindForm(forms.Form):
models.IntegrityType.get_types(empty_first=False)
self.fields['integritie'].help_text = \
models.IntegrityType.get_help()
+ self.fields['remarkabilitie'].choices = \
+ models.RemarkabilityType.get_types(empty_first=False)
+ self.fields['remarkabilitie'].help_text = \
+ models.RemarkabilityType.get_help()
+ self.fields['estimated_value'].label = u"{} ({})".format(
+ unicode(self.fields['estimated_value'].label),
+ get_current_profile().currency)
class DateForm(forms.Form):
@@ -194,13 +209,19 @@ class FindSelect(TableSelect):
base_finds__context_record__operation__year = forms.IntegerField(
label=_(u"Year"))
base_finds__context_record__operation__code_patriarche = \
- forms.IntegerField(label=_(u"Code PATRIARCHE"))
+ forms.IntegerField(
+ label=_(u"Code PATRIARCHE"),
+ widget=OAWidget
+ )
archaeological_sites = forms.IntegerField(
label=_("Archaelogical site"),
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-archaeologicalsite'),
associated_model=ArchaeologicalSite),
validators=[valid_id(ArchaeologicalSite)])
+ ope_relation_types = forms.MultipleChoiceField(
+ label=_(u"Search within operation relations"), choices=[],
+ widget=forms.CheckboxSelectMultiple)
datings__period = forms.ChoiceField(label=_(u"Period"), choices=[])
# TODO search by warehouse
material_types = forms.ChoiceField(label=_(u"Material type"), choices=[])
@@ -210,6 +231,8 @@ class FindSelect(TableSelect):
conservatory_state = forms.ChoiceField(label=_(u"Conservatory state"),
choices=[])
integrities = forms.ChoiceField(label=_(u"Integrity"), choices=[])
+ remarkabilities = forms.ChoiceField(label=_(u"Remarkability"),
+ choices=[])
base_finds__find__description = forms.CharField(label=_(u"Description"))
base_finds__batch = forms.ChoiceField(
label=_(u"Batch/object"),
@@ -241,6 +264,19 @@ class FindSelect(TableSelect):
models.IntegrityType.get_types()
self.fields['integrities'].help_text = \
models.IntegrityType.get_help()
+ self.fields['remarkabilities'].choices = \
+ models.RemarkabilityType.get_types()
+ self.fields['remarkabilities'].help_text = \
+ models.RemarkabilityType.get_help()
+ self.fields['ope_relation_types'].choices = OpeRelationType.get_types(
+ empty_first=False)
+
+ def get_input_ids(self):
+ ids = super(FindSelect, self).get_input_ids()
+ ids.pop(ids.index('ope_relation_types'))
+ for idx, c in enumerate(self.fields['ope_relation_types'].choices):
+ ids.append('ope_relation_types_{}'.format(idx))
+ return ids
class FindFormSelection(forms.Form):
@@ -416,6 +452,13 @@ SourceFindFormSelection = get_form_selection(
class FindSourceSelect(SourceSelect):
find__base_finds__context_record__operation__year = forms.IntegerField(
label=_(u"Year of the operation"))
+ find__base_finds__context_record__operation__operation_code = \
+ forms.IntegerField(label=_(u"Numeric reference"))
+ if settings.COUNTRY == 'fr':
+ find__base_finds__context_record__operation__code_patriarche = \
+ forms.IntegerField(
+ widget=OAWidget,
+ label="Code PATRIARCHE")
find__datings__period = forms.ChoiceField(
label=_(u"Period of the archaelogical find"), choices=[])
find__material_type = forms.ChoiceField(