summaryrefslogtreecommitdiff
path: root/ishtar/furnitures/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar/furnitures/forms.py')
-rw-r--r--ishtar/furnitures/forms.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py
index 7f9347197..b78a06644 100644
--- a/ishtar/furnitures/forms.py
+++ b/ishtar/furnitures/forms.py
@@ -33,6 +33,7 @@ from merlin.wizards.session import SessionWizard
import models
import widgets
+from ishtar import settings
from django.utils.functional import lazy
@@ -58,7 +59,7 @@ class Wizard(SessionWizard):
class FileWizard(Wizard):
def get_template(self, request, step, form):
- return ['templates/file_wizard_%s.html' % step,
+ return ['file_wizard_%s.html' % step,
'file_wizard.html']
def done(self, request, form_list):
@@ -66,6 +67,20 @@ class FileWizard(Wizard):
'form_data': [form.cleaned_data for form in form_list],
})
+ def process_step(self, request, step, form):
+ if models.PREVENTIVE and 'file_type' in form.cleaned_data:
+ file_type = int(form.cleaned_data['file_type'])
+ if file_type == models.PREVENTIVE:
+ preventive_step = Step('preventive',
+ _(u"Preventive informations"), FileForm3)
+ localisation_step = self.get_step(request, 'localisation')
+ self.insert_after(request, localisation_step,
+ preventive_step)
+ else:
+ preventive_step = self.get_step(request, 'preventive')
+ self.remove_step(request, preventive_step)
+
+
class FileForm1(forms.Form):
in_charge = forms.IntegerField(label=_("Person in charge"),
widget=widgets.JQueryAutoComplete(reverse_lazy('autocomplete-person'),
@@ -84,5 +99,22 @@ class FileForm1(forms.Form):
class FileForm2(forms.Form):
- town = forms.IntegerField(label=_(u"Town"))
-
+ town = forms.IntegerField(label=_(u"Town"),
+ widget=widgets.JQueryAutoComplete(reverse_lazy('autocomplete-town'),
+ associated_model=models.Town),
+ validators=[models.Town.valid_id])
+ total_surface = forms.IntegerField(label=_("Total surface"))
+ address = forms.CharField(label=_(u"Address"), widget=forms.Textarea)
+
+class FileForm3(forms.Form):
+ general_contractor = forms.IntegerField(label=_(u"General contractor"),
+ widget=widgets.JQueryAutoComplete(
+ reverse_lazy('autocomplete-organization'),
+ associated_model=models.Organization),
+ validators=[models.Organization.valid_id])
+ total_developed_surface = forms.IntegerField(
+ label=_("Total developed surface"))
+ if settings.COUNTRY == 'fr':
+ saisine_type = forms.ChoiceField(label=_("Saisine type"),
+ choices=models.SaisineType.get_types())
+ reception_date = forms.DateField(label=_(u"Reception date"))