diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-01-04 00:06:11 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-01-04 00:06:11 +0100 |
commit | bf6ed908e0184a7351953f4162ac250b0e8bbc7e (patch) | |
tree | 33e644a8a30477b86510508bfd0d0eabf4e5fff1 | |
parent | 0961e46bfc73e839115dd8a71edfc9af40c1f401 (diff) | |
download | Ishtar-bf6ed908e0184a7351953f4162ac250b0e8bbc7e.tar.bz2 Ishtar-bf6ed908e0184a7351953f4162ac250b0e8bbc7e.zip |
Dissociate Town for archeological files (refs #14)
-rw-r--r-- | ishtar/furnitures/forms.py | 41 | ||||
-rw-r--r-- | ishtar/furnitures/widgets.py | 2 | ||||
-rw-r--r-- | ishtar/templates/file_wizard.html | 7 | ||||
-rw-r--r-- | static/media/style.css | 3 |
4 files changed, 25 insertions, 28 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index 3732bd528..de221da70 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -26,11 +26,9 @@ from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from django.template import Context, RequestContext from django.shortcuts import render_to_response +from django.forms.formsets import formset_factory from django import forms -from merlin.wizards.utils import Step as BasicStep -from merlin.wizards.session import SessionWizard - from formwizard.forms import NamedUrlSessionFormWizard import models @@ -43,10 +41,13 @@ reverse_lazy = lazy(reverse, unicode) class Wizard(NamedUrlSessionFormWizard): def get_template_context(self, request, storage, form=None): + """ + Add previous and current steps to manage the wizard path + """ context = super(Wizard, self).get_template_context(request, storage, form) step = self.get_first_step(request, storage) - current_step = storage.get_current_step() + current_step = storage.get_current_step() or '0' context.update({'current_step':self.form_list[current_step]}) if step == current_step: return context @@ -71,20 +72,6 @@ class FileWizard(Wizard): {'form_list': [form.cleaned_data for form in form_list]}, context_instance=RequestContext(request) ) - """ - 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): form_label = _("General") @@ -105,13 +92,19 @@ class FileForm1(forms.Form): class FileForm2(forms.Form): form_label = _("Address") - 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 TownForm(forms.Form): + form_label = _("Towns") + # !FIXME hard_link, reverse_lazy doen't seem to work with formsets + town = forms.IntegerField(label=_(u"Town"), + widget=widgets.JQueryAutoComplete("/" + settings.URL_PATH + \ + 'autocomplete-town', associated_model=models.Town), + validators=[models.Town.valid_id]) + +TownFormSet = formset_factory(TownForm) +TownFormSet.form_label = _("Towns") class FileForm3(forms.Form): form_label = _("Preventive informations") @@ -140,6 +133,6 @@ def is_preventive(self, request, storage): except ValueError: return False -file_creation_wizard = FileWizard([FileForm1, FileForm2, FileForm3], - url_name='file_creation', condition_list={'2':is_preventive}) +file_creation_wizard = FileWizard([FileForm1, FileForm2, TownFormSet, FileForm3], + url_name='file_creation', condition_list={'3':is_preventive}) diff --git a/ishtar/furnitures/widgets.py b/ishtar/furnitures/widgets.py index fd9077b5e..899d66307 100644 --- a/ishtar/furnitures/widgets.py +++ b/ishtar/furnitures/widgets.py @@ -46,7 +46,7 @@ class JQueryAutoComplete(forms.TextInput): source = "'%s'" % escape(self.source)
else:
try:
- source = "'" + unicode(self.source) +"'"
+ source = "'" + unicode(self.source) + "'"
except:
raise ValueError('source type is not valid')
options = 'source : ' + source
diff --git a/ishtar/templates/file_wizard.html b/ishtar/templates/file_wizard.html index 9ebf4adb3..eaf40cc15 100644 --- a/ishtar/templates/file_wizard.html +++ b/ishtar/templates/file_wizard.html @@ -10,16 +10,19 @@ <li class='current'>» <a href='#'>{{current_step.form_label}}</a></li> </ul> <div class='form'> -<table> {% if form.forms %} +<table class='formset'> {{ form.management_form }} {% for formsetform in form.forms %} {{ formsetform.as_table }} {% endfor %} + <tr><td rowspan="2"><button name="form_prev_step" value="{{form_step}}">{% trans "Modify" %}</button></td></tr></li> +</table> {% else %} +<table> {{ form.as_table }} -{% endif %} </table> +{% endif %} <input type="hidden" name="{{ step_field }}" value="{{ step0 }}" /> {{ previous_fields|safe }} <input type="submit" value="{% trans "Validate" %}"/> diff --git a/static/media/style.css b/static/media/style.css index 47f30b2ee..2d58631dc 100644 --- a/static/media/style.css +++ b/static/media/style.css @@ -13,7 +13,7 @@ a { color:#D14; } -button { +ul#form_path button { text-decoration:none; color:#D14; border:none; @@ -22,6 +22,7 @@ button { cursor:pointer; padding:0; margin:0; + font-family:Arial, Helvetica, sans-serif; } caption { |