misc: don't repeat title identical to page name on summary page (#26732)
This commit is contained in:
parent
16cd56c158
commit
dfe2cba424
|
@ -1058,6 +1058,27 @@ def test_form_multi_page_page_name_as_title(pub):
|
|||
assert 'Check values then click submit.' in next_page.body
|
||||
assert next_page.body.count('1st page') == 2 # in steps and in main body
|
||||
|
||||
# add a comment that will not be displayed and should therefore not be
|
||||
# considered.
|
||||
formdef.fields = [fields.PageField(id='0', label='1st page', type='page'),
|
||||
fields.CommentField(id='5', label='bla bla bla', type='comment'),
|
||||
fields.TitleField(id='4', label='1st page', type='title'),
|
||||
fields.StringField(id='1', label='string'),
|
||||
fields.PageField(id='2', label='2nd page', type='page'),
|
||||
fields.StringField(id='3', label='string 2')]
|
||||
formdef.store()
|
||||
page = get_app(pub).get('/test/')
|
||||
formdef.data_class().wipe()
|
||||
page.forms[0]['f1'] = 'foo'
|
||||
next_page = page.forms[0].submit('submit')
|
||||
assert_current_page(next_page, '2nd page')
|
||||
assert next_page.forms[0]['previous']
|
||||
next_page.forms[0]['f3'] = 'bar'
|
||||
next_page = next_page.forms[0].submit('submit')
|
||||
assert_current_page(next_page, 'Validating')
|
||||
assert 'Check values then click submit.' in next_page.body
|
||||
assert next_page.body.count('1st page') == 2 # in steps and in main body
|
||||
|
||||
def test_form_submit_with_user(pub, emails):
|
||||
create_user(pub)
|
||||
formdef = create_formdef()
|
||||
|
|
|
@ -559,6 +559,7 @@ class FormDef(StorableObject):
|
|||
form.attrs['style'] = 'display: none;'
|
||||
if self.keywords:
|
||||
form.attrs['data-keywords'] = ' '.join(self.keywords_list)
|
||||
current_page_fields = []
|
||||
on_disabled_page = False
|
||||
on_page = False
|
||||
for i, field in enumerate(self.fields):
|
||||
|
@ -585,17 +586,23 @@ class FormDef(StorableObject):
|
|||
form.widgets.append(HtmlWidget(
|
||||
htmltext('<div class="page"><h3>%s</h3><div>' % field.label)))
|
||||
on_page = field
|
||||
current_page_fields = []
|
||||
continue
|
||||
|
||||
if field.type == 'title' and on_page and (
|
||||
self.fields[i-1] is on_page and
|
||||
not current_page_fields and
|
||||
on_page.label == field.label):
|
||||
# don't include first title of a page if that title has the
|
||||
# same text as the page.
|
||||
continue
|
||||
|
||||
if field.type in ('comment', 'page'):
|
||||
continue
|
||||
|
||||
if not field.is_visible(dict, self):
|
||||
continue
|
||||
|
||||
current_page_fields.append(field)
|
||||
value = dict.get(field.id, '')
|
||||
field.add_to_view_form(form, value)
|
||||
|
||||
|
|
|
@ -362,7 +362,7 @@ class FormStatusPage(Directory, FormTemplateMixin):
|
|||
pages.append({'page': f, 'fields': current_page_fields})
|
||||
continue
|
||||
|
||||
if f.type == 'title' and on_page and fields[i-1] is on_page and on_page.label == f.label:
|
||||
if f.type == 'title' and on_page and not current_page_fields and on_page.label == f.label:
|
||||
# don't include first title of a page if that title has the
|
||||
# same text as the page.
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue