0001-misc-use-a-django-template-to-render-form-steps-2656.patch
tests/test_form_pages.py | ||
---|---|---|
464 | 464 |
assert data.data['0_display'] == 'Foo, Bar' |
465 | 465 | |
466 | 466 |
def assert_current_page(resp, page_label): |
467 |
assert re.findall('<li class=".*?current.*?">.*?<span class="label">(.*?)</span></li>', |
|
468 |
resp.body)[0] == page_label |
|
467 |
for li_tag in resp.html.findAll('li'): |
|
468 |
if 'current' in li_tag.attrs['class']: |
|
469 |
assert li_tag.find_all('span')[-1].text == page_label |
|
469 | 470 | |
470 | 471 |
def test_form_multi_page(pub): |
471 | 472 |
for initial_condition in (None, 'True'): |
wcs/backoffice/submission.py | ||
---|---|---|
79 | 79 | |
80 | 80 |
filling_templates = ['wcs/formdata_filling.html'] |
81 | 81 |
validation_templates = ['wcs/formdata_validation.html'] |
82 |
steps_templates = ['wcs/formdata_steps.html'] |
|
82 | 83 | |
83 | 84 |
def __init__(self, *args, **kwargs): |
84 | 85 |
super(FormFillPage, self).__init__(*args, **kwargs) |
wcs/forms/root.py | ||
---|---|---|
177 | 177 |
do_not_call_in_templates = True |
178 | 178 |
filling_templates = ['wcs/front/formdata_filling.html', 'wcs/formdata_filling.html'] |
179 | 179 |
validation_templates = ['wcs/front/formdata_validation.html', 'wcs/formdata_validation.html'] |
180 |
steps_templates = ['wcs/front/formdata_steps.html', 'wcs/formdata_steps.html'] |
|
180 | 181 | |
181 | 182 |
def __init__(self, component): |
182 | 183 |
try: |
... | ... | |
253 | 254 |
if self.has_confirmation_page() and not self.edit_mode: |
254 | 255 |
page_labels.append(_('Validating')) |
255 | 256 | |
256 |
r = TemplateIO(html=True) |
|
257 |
r += htmltext('<div id="steps" class="steps-%s"><ol>') % len(page_labels) |
|
258 | ||
259 |
for i, page_label in enumerate(page_labels): |
|
260 |
classes = [] |
|
261 |
index = i + 1 |
|
262 |
if index == 1: |
|
263 |
classes.append('first') |
|
264 |
if index == len(page_labels): |
|
265 |
classes.append('last') |
|
266 |
if index == current_position: |
|
267 |
classes.append('current') |
|
268 |
elif index < current_position: |
|
269 |
classes.append('step-before') |
|
270 |
elif index > current_position: |
|
271 |
classes.append('step-after') |
|
272 |
r += htmltext('<li class="%s">') % ' '.join(classes) |
|
273 |
r += htmltext('<span class="marker">%d</span> <span class="label">%s</span>') % ( |
|
274 |
index, page_label) |
|
275 |
r += htmltext('</li>') |
|
276 | ||
277 |
r += htmltext('</ol></div>') |
|
278 |
return r.getvalue() |
|
257 |
return template.render( |
|
258 |
list(self.get_formdef_template_variants(self.steps_templates)), |
|
259 |
{ |
|
260 |
'page_labels': page_labels, |
|
261 |
'current_page_no': current_position, |
|
262 |
}) |
|
279 | 263 | |
280 | 264 |
def page(self, page, page_change=True, page_error_messages=None): |
281 | 265 |
displayed_fields = [] |
wcs/templates/wcs/formdata_steps.html | ||
---|---|---|
1 |
<div id="steps" class="steps-{{page_labels|length}}"> |
|
2 |
<ol> |
|
3 |
{% for page_label in page_labels %} |
|
4 |
{% spaceless %} |
|
5 |
<li class="{% if forloop.first %}first{% endif %} |
|
6 |
{% if forloop.last %}last{% endif %} |
|
7 |
{% if forloop.counter == current_page_no %}current{% endif %} |
|
8 |
{% if forloop.counter < current_page_no %}step-before{% endif %} |
|
9 |
{% if forloop.counter > current_page_no %}step-after{% endif %}" > |
|
10 |
<span class="marker">{{ forloop.counter }}</span> |
|
11 |
<span class="label">{{ page_label }}</span> |
|
12 |
</li> |
|
13 |
{% endspaceless %} |
|
14 |
{% endfor %} |
|
15 |
</ol> |
|
16 |
</div> |
|
0 |
- |