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.py55
1 files changed, 30 insertions, 25 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index deb9ce4dc..30a5a40fa 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -94,28 +94,33 @@ class FindForm(forms.Form):
class DateForm(forms.Form):
form_label = _("Dating")
base_model = 'dating'
- associated_models = {'dating__dating_type': DatingType,
- 'dating__quality': DatingQuality,
- 'dating__period': Period}
- dating__period = forms.ChoiceField(label=_("Period"), choices=[])
- dating__start_date = forms.IntegerField(label=_(u"Start date"),
- required=False)
- dating__end_date = forms.IntegerField(label=_(u"End date"), required=False)
- dating__quality = forms.ChoiceField(label=_("Quality"), required=False,
- choices=[])
- dating__dating_type = forms.ChoiceField(label=_("Dating type"),
- required=False, choices=[])
- dating__precise_dating = forms.CharField(label=_("Precise dating"),
- required=False)
+ associated_models = {'dating_type': DatingType,
+ 'quality': DatingQuality,
+ 'period': Period}
+ period = forms.ChoiceField(label=_("Period"), choices=[])
+ start_date = forms.IntegerField(label=_(u"Start date"),
+ required=False)
+ end_date = forms.IntegerField(label=_(u"End date"), required=False)
+ quality = forms.ChoiceField(label=_("Quality"), required=False,
+ choices=[])
+ dating_type = forms.ChoiceField(label=_("Dating type"),
+ required=False, choices=[])
+ precise_dating = forms.CharField(label=_("Precise dating"),
+ required=False)
def __init__(self, *args, **kwargs):
super(DateForm, self).__init__(*args, **kwargs)
- self.fields['dating__dating_type'].choices = DatingType.get_types()
- self.fields['dating__dating_type'].help_text = DatingType.get_help()
- self.fields['dating__period'].choices = Period.get_types()
- self.fields['dating__period'].help_text = Period.get_help()
- self.fields['dating__quality'].choices = DatingQuality.get_types()
- self.fields['dating__quality'].help_text = DatingQuality.get_help()
+ self.fields['dating_type'].choices = DatingType.get_types()
+ self.fields['dating_type'].help_text = DatingType.get_help()
+ self.fields['period'].choices = Period.get_types()
+ self.fields['period'].help_text = Period.get_help()
+ self.fields['quality'].choices = DatingQuality.get_types()
+ self.fields['quality'].help_text = DatingQuality.get_help()
+
+
+DatingFormSet = formset_factory(DateForm, can_delete=True,
+ formset=FormSet)
+DatingFormSet.form_label = _("Dating")
class FindSelect(TableSelect):
@@ -124,7 +129,7 @@ class FindSelect(TableSelect):
label=_(u"Year"))
base_finds__context_record__operation__code_patriarche = \
forms.IntegerField(label=_(u"Code PATRIARCHE"))
- dating__period = forms.ChoiceField(label=_(u"Period"), choices=[])
+ 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=[])
@@ -136,8 +141,8 @@ class FindSelect(TableSelect):
def __init__(self, *args, **kwargs):
super(FindSelect, self).__init__(*args, **kwargs)
- self.fields['dating__period'].choices = Period.get_types()
- self.fields['dating__period'].help_text = Period.get_help()
+ self.fields['datings__period'].choices = Period.get_types()
+ self.fields['datings__period'].help_text = Period.get_help()
self.fields['material_types'].choices = \
models.MaterialType.get_types()
self.fields['material_types'].help_text = \
@@ -276,7 +281,7 @@ SourceFindFormSelection = get_form_selection(
class FindSourceSelect(SourceSelect):
find__base_finds__context_record__operation__year = forms.IntegerField(
label=_(u"Year of the operation"))
- find__dating__period = forms.ChoiceField(
+ find__datings__period = forms.ChoiceField(
label=_(u"Period of the archaelogical find"), choices=[])
find__material_type = forms.ChoiceField(
label=_("Material type of the archaelogical find"), choices=[])
@@ -285,8 +290,8 @@ class FindSourceSelect(SourceSelect):
def __init__(self, *args, **kwargs):
super(FindSourceSelect, self).__init__(*args, **kwargs)
- self.fields['find__dating__period'].choices = Period.get_types()
- self.fields['find__dating__period'].help_text = Period.get_help()
+ self.fields['find__datings__period'].choices = Period.get_types()
+ self.fields['find__datings__period'].help_text = Period.get_help()
self.fields['find__material_type'].choices = \
models.MaterialType.get_types()
self.fields['find__material_type'].help_text = \