summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-04-13 17:11:50 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-04-13 17:13:06 +0200
commit3ccc3a15c541763431baf33ffb605fff9cdaec65 (patch)
tree938b4e94156cc9fe39fa7e7218b66aeafe709214 /archaeological_finds/forms.py
parent885cac313e1c937f93379a9a234ca178cc75ab0d (diff)
downloadIshtar-3ccc3a15c541763431baf33ffb605fff9cdaec65.tar.bz2
Ishtar-3ccc3a15c541763431baf33ffb605fff9cdaec65.zip
Finds - fields: add clutter dimensions and material, object type quality types
Diffstat (limited to 'archaeological_finds/forms.py')
-rw-r--r--archaeological_finds/forms.py38
1 files changed, 32 insertions, 6 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 15d86f91f..ac58780f0 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -135,12 +135,15 @@ class FindForm(CustomForm, ManageOldType):
form_slug = "find-020-general"
base_models = ['get_first_base_find', 'object_type', 'material_type',
'communicabilitie']
- associated_models = {'material_type': models.MaterialType,
- 'object_type': models.ObjectType,
- 'communicabilitie': models.CommunicabilityType,
- 'get_first_base_find__batch': models.BatchType,
- 'get_first_base_find__spatial_reference_system':
- SpatialReferenceSystem}
+ associated_models = {
+ 'material_type': models.MaterialType,
+ 'object_type': models.ObjectType,
+ 'communicabilitie': models.CommunicabilityType,
+ 'get_first_base_find__batch': models.BatchType,
+ 'get_first_base_find__spatial_reference_system': SpatialReferenceSystem,
+ 'material_type_quality': models.MaterialTypeQualityType,
+ 'object_type_quality': models.ObjectTypeQualityType
+ }
HEADERS = {}
HEADERS['label'] = FormHeader(_(u"Identification"))
@@ -171,9 +174,13 @@ class FindForm(CustomForm, ManageOldType):
material_type = widgets.Select2MultipleField(
label=_(u"Material types"), required=False
)
+ material_type_quality = forms.ChoiceField(
+ label=_(u"Material type quality"), required=False, choices=[])
object_type = widgets.Select2MultipleField(
label=_(u"Object types"), required=False,
)
+ object_type_quality = forms.ChoiceField(
+ label=_(u"Object type quality"), required=False, choices=[])
find_number = forms.IntegerField(label=_(u"Find number"), required=False)
min_number_of_individuals = forms.IntegerField(
label=_(u"Minimum number of individuals (MNI)"), required=False)
@@ -203,6 +210,12 @@ class FindForm(CustomForm, ManageOldType):
thickness = FloatField(label=_(u"Thickness (cm)"), required=False)
volume = FloatField(label=_(u"Volume (l)"), required=False)
weight = FloatField(label=_(u"Weight (g)"), required=False)
+ clutter_long_side = FloatField(
+ label=_(u"Clutter long side (cm)"), required=False)
+ clutter_short_side = FloatField(
+ label=_(u"Clutter short side (cm)"), required=False)
+ clutter_height = FloatField(
+ label=_(u"Clutter height (cm)"), required=False)
dimensions_comment = forms.CharField(
label=_(u"Dimensions comment"), required=False, widget=forms.Textarea)
@@ -232,7 +245,9 @@ class FindForm(CustomForm, ManageOldType):
TYPES = [
FieldType('material_type', models.MaterialType, is_multiple=True),
+ FieldType('material_type_quality', models.MaterialTypeQualityType),
FieldType('object_type', models.ObjectType, is_multiple=True),
+ FieldType('object_type_quality', models.ObjectTypeQualityType),
FieldType('communicabilitie', models.CommunicabilityType,
is_multiple=True),
FieldType('get_first_base_find__batch', models.BatchType),
@@ -273,6 +288,17 @@ class FindForm(CustomForm, ManageOldType):
unicode(_(u"Discovery date: TAQ date must be older than TPQ "
u"date.")))
+ clutter_long_side = self.cleaned_data.get('clutter_long_side', None)
+ clutter_short_side = self.cleaned_data.get('clutter_short_side', None)
+
+ if clutter_long_side and clutter_short_side and \
+ clutter_short_side > clutter_long_side:
+ raise forms.ValidationError(
+ unicode(_(
+ u"Clutter: short side cannot be bigger than the long side."
+ ))
+ )
+
if not get_current_profile().mapping:
return self.cleaned_data
x = self.cleaned_data.get('get_first_base_find__x', None)