0001-misc-don-t-repeat-title-identical-to-page-name-on-su.patch
tests/test_form_pages.py | ||
---|---|---|
1058 | 1058 |
assert 'Check values then click submit.' in next_page.body |
1059 | 1059 |
assert next_page.body.count('1st page') == 2 # in steps and in main body |
1060 | 1060 | |
1061 |
# add a comment that will not be displayed and should therefore not be |
|
1062 |
# considered. |
|
1063 |
formdef.fields = [fields.PageField(id='0', label='1st page', type='page'), |
|
1064 |
fields.CommentField(id='5', label='bla bla bla', type='comment'), |
|
1065 |
fields.TitleField(id='4', label='1st page', type='title'), |
|
1066 |
fields.StringField(id='1', label='string'), |
|
1067 |
fields.PageField(id='2', label='2nd page', type='page'), |
|
1068 |
fields.StringField(id='3', label='string 2')] |
|
1069 |
formdef.store() |
|
1070 |
page = get_app(pub).get('/test/') |
|
1071 |
formdef.data_class().wipe() |
|
1072 |
page.forms[0]['f1'] = 'foo' |
|
1073 |
next_page = page.forms[0].submit('submit') |
|
1074 |
assert_current_page(next_page, '2nd page') |
|
1075 |
assert next_page.forms[0]['previous'] |
|
1076 |
next_page.forms[0]['f3'] = 'bar' |
|
1077 |
next_page = next_page.forms[0].submit('submit') |
|
1078 |
assert_current_page(next_page, 'Validating') |
|
1079 |
assert 'Check values then click submit.' in next_page.body |
|
1080 |
assert next_page.body.count('1st page') == 2 # in steps and in main body |
|
1081 | ||
1061 | 1082 |
def test_form_submit_with_user(pub, emails): |
1062 | 1083 |
create_user(pub) |
1063 | 1084 |
formdef = create_formdef() |
wcs/fields.py | ||
---|---|---|
623 | 623 |
form.widgets.append(widget) |
624 | 624 |
return widget |
625 | 625 | |
626 |
def add_to_view_form(self, *args): |
|
627 |
pass |
|
626 |
add_to_view_form = None |
|
628 | 627 | |
629 | 628 |
def fill_admin_form(self, form): |
630 | 629 |
if self.label and (not self.label.startswith('<') and ( |
... | ... | |
1689 | 1688 |
changed = True |
1690 | 1689 |
return changed |
1691 | 1690 | |
1692 |
def add_to_view_form(self, *args): |
|
1693 |
pass |
|
1691 |
add_to_view_form = None |
|
1694 | 1692 | |
1695 | 1693 |
register_field_class(PageField) |
1696 | 1694 |
wcs/formdef.py | ||
---|---|---|
571 | 571 |
form.attrs['style'] = 'display: none;' |
572 | 572 |
if self.keywords: |
573 | 573 |
form.attrs['data-keywords'] = ' '.join(self.keywords_list) |
574 |
current_page_fields = [] |
|
574 | 575 |
on_disabled_page = False |
575 | 576 |
on_page = False |
576 | 577 |
for i, field in enumerate(self.fields): |
... | ... | |
597 | 598 |
form.widgets.append(HtmlWidget( |
598 | 599 |
htmltext('<div class="page"><h3>%s</h3><div>' % field.label))) |
599 | 600 |
on_page = field |
601 |
current_page_fields = [] |
|
602 |
continue |
|
600 | 603 | |
601 | 604 |
if field.type == 'title' and on_page and ( |
602 |
self.fields[i-1] is on_page and
|
|
605 |
not current_page_fields and
|
|
603 | 606 |
on_page.label == field.label): |
604 | 607 |
# don't include first title of a page if that title has the |
605 | 608 |
# same text as the page. |
606 | 609 |
continue |
607 | 610 | |
608 |
if not field.is_visible(dict, self): |
|
611 |
if field.add_to_view_form is None or not field.is_visible(dict, self):
|
|
609 | 612 |
continue |
610 | 613 | |
614 |
current_page_fields.append(field) |
|
611 | 615 |
value = dict.get(field.id, '') |
612 | 616 |
field.add_to_view_form(form, value) |
613 | 617 |
wcs/forms/common.py | ||
---|---|---|
362 | 362 |
pages.append({'page': f, 'fields': current_page_fields}) |
363 | 363 |
continue |
364 | 364 | |
365 |
if f.type == 'title' and on_page and fields[i-1] is on_page and on_page.label == f.label:
|
|
365 |
if f.type == 'title' and on_page and not current_page_fields and on_page.label == f.label:
|
|
366 | 366 |
# don't include first title of a page if that title has the |
367 | 367 |
# same text as the page. |
368 | 368 |
continue |
369 |
- |