"validation" button on validation page

This commit is contained in:
Thomas NOËL 2012-05-21 14:57:57 +02:00
parent eec4bcd8b7
commit cb4e5d36aa
2 changed files with 15 additions and 4 deletions

View File

@ -21,6 +21,7 @@
<br />
{% for step, form, pprint_data in all_forms %}
{% if not forloop.last %}{# don't process last step == validation #}
<h3><a href="../{{ step }}">Étape {{ forloop.counter }}. {{ form.display_name }}</a></h3>
<ul>
{% for d,v in pprint_data %}
@ -29,16 +30,21 @@
{% endif %}
{% endfor %}
</ul>
</li>
</li>
{% endif %}
{% endfor %}
{{ wizard.management_form }}
{% crispy wizard.form %}
<div class="form-actions">
<button name="submit" type="submit" class="btn pull-right"/>Valider <i class="icon-ok"></i></button>
{% if validated %}
<button name="submit" type="submit" class="btn pull-right btn-success"/>Valider la demande <i class="icon-ok"></i></button>
{% if wizard.steps.prev %}
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}" class="btn pull-left"><i class="icon-backward"></i> Retour</button>
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}" class="btn pull-left"> <i class="icon-backward"></i> Retour</button>
{% endif %}
{% else %}
<button name="submit" type="submit" class="btn btn-warning pull-left"/><i class="icon-repeat"></i> Retour sur l'étape invalide</i></button>
{% endif %}
</div>

View File

@ -58,15 +58,20 @@ class RequestWizardView(NamedUrlSessionWizardView):
view of the stored datas
'''
context = super(RequestWizardView, self).get_context_data(form=form, **kwargs)
cleaned_data = self.get_all_cleaned_data() or {}
# cleaned_data = self.get_all_cleaned_data() or {}
all_forms = []
validated = True
for step, form in self.get_form_list().items():
cleaned_data = self.get_cleaned_data_for_step(step)
if (step != self.steps.last) and (cleaned_data is None):
validated = False
if cleaned_data and hasattr(form, 'pprint_data'):
pprint_data = form().pprint_data(cleaned_data)
else:
pprint_data = []
all_forms += [ (step, form, pprint_data) ]
context['all_forms'] = all_forms
context['validated'] = validated
return context