summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-12-13 17:16:25 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-12-13 17:16:25 +0100
commitc7df405569c69fc89a778754c96be81eafadea25 (patch)
tree348df4d7f645b90ba757403b1f260aff9bcdd93e /archaeological_operations
parentdbfc67f0f44ad1cdc6fff1775102e6538847d9bc (diff)
downloadIshtar-c7df405569c69fc89a778754c96be81eafadea25.tar.bz2
Ishtar-c7df405569c69fc89a778754c96be81eafadea25.zip
Operation forms: improve remain and period forms
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/forms.py38
-rw-r--r--archaeological_operations/views.py8
2 files changed, 14 insertions, 32 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 5aaee4112..3d679d555 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -805,50 +805,32 @@ class RemainForm(forms.Form):
form_label = _("Remain types")
base_model = 'remain'
associated_models = {'remain': models.RemainType}
- remain = forms.ChoiceField(label=_("Remain type"), required=False,
- choices=[])
+ remain = forms.MultipleChoiceField(
+ label=_("Remain type"), required=False, choices=[],
+ widget=forms.CheckboxSelectMultiple)
def __init__(self, *args, **kwargs):
super(RemainForm, self).__init__(*args, **kwargs)
- self.fields['remain'].choices = models.RemainType.get_types()
+ self.fields['remain'].choices = models.RemainType.get_types(
+ empty_first=False)
self.fields['remain'].help_text = models.RemainType.get_help()
-class RemainFormSet(FormSet):
- def clean(self):
- """Checks that no remain types are duplicated."""
- return self.check_duplicate(['remain_type'],
- _(u"There are identical remain types"))
-
-RemainFormset = formset_factory(RemainForm, can_delete=True,
- formset=RemainFormSet)
-RemainFormset.form_label = _("Remain types")
-
-
class PeriodForm(forms.Form):
form_label = _("Periods")
base_model = 'period'
associated_models = {'period': models.Period}
- period = forms.ChoiceField(label=_("Period"), required=False,
- choices=[])
+ period = forms.MultipleChoiceField(
+ label=_("Period"), required=False, choices=[],
+ widget=forms.CheckboxSelectMultiple)
def __init__(self, *args, **kwargs):
super(PeriodForm, self).__init__(*args, **kwargs)
- self.fields['period'].choices = models.Period.get_types()
+ self.fields['period'].choices = models.Period.get_types(
+ empty_first=False)
self.fields['period'].help_text = models.Period.get_help()
-class PeriodFormSet(FormSet):
- def clean(self):
- """Checks that no period are duplicated."""
- return self.check_duplicate(['period'],
- _(u"There are identical periods"))
-
-PeriodFormset = formset_factory(PeriodForm, can_delete=True,
- formset=PeriodFormSet)
-PeriodFormset.form_label = _("Periods")
-
-
class ArchaeologicalSiteForm(forms.Form):
reference = forms.CharField(label=_(u"Reference"), max_length=20)
name = forms.CharField(label=_(u"Name"), max_length=200, required=False)
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 3af75da23..ae722d2bc 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -209,8 +209,8 @@ wizard_steps = [
('towns-operation_creation', SelectedTownFormset),
('parcelsgeneral-operation_creation', SelectedParcelGeneralFormSet),
('parcels-operation_creation', SelectedParcelFormSet),
- ('remains-operation_creation', RemainFormset),
- ('periods-operation_creation', PeriodFormset),
+ ('remains-operation_creation', RemainForm),
+ ('periods-operation_creation', PeriodForm),
('final-operation_creation', FinalForm)]
if FILES_AVAILABLE:
wizard_steps.insert(0, ('filechoice-operation_creation',
@@ -246,8 +246,8 @@ operation_modification_wizard = OperationModificationWizard.as_view([
('townsgeneral-operation_modification', TownFormset),
('parcels-operation_modification', SelectedParcelFormSet),
('parcelsgeneral-operation_modification', SelectedParcelGeneralFormSet),
- ('remains-operation_modification', RemainFormset),
- ('periods-operation_modification', PeriodFormset),
+ ('remains-operation_modification', RemainForm),
+ ('periods-operation_modification', PeriodForm),
('final-operation_modification', FinalForm)],
label=_(u"Operation modification"),
condition_dict={