custom views: don't fail if columns do not exist (#51296)
This commit is contained in:
parent
2cb7da958b
commit
a8d01e3da7
|
@ -468,6 +468,43 @@ def test_backoffice_missing_custom_view(pub):
|
|||
assert resp.location == 'http://example.net/backoffice/management/form-title/1/?plop'
|
||||
|
||||
|
||||
def test_backoffice_custom_view_columns(pub):
|
||||
create_superuser(pub)
|
||||
|
||||
FormDef.wipe()
|
||||
pub.custom_view_class.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = [
|
||||
fields.ItemField(
|
||||
id='1',
|
||||
label='field 1',
|
||||
type='item',
|
||||
items=['foo', 'bar', 'baz'],
|
||||
display_locations=['validation', 'summary', 'listings'],
|
||||
),
|
||||
]
|
||||
formdef.workflow_roles = {'_receiver': 1}
|
||||
formdef.store()
|
||||
|
||||
custom_view = pub.custom_view_class()
|
||||
custom_view.title = 'shared custom test view'
|
||||
custom_view.formdef = formdef
|
||||
custom_view.visibility = 'any'
|
||||
custom_view.columns = {'list': [{'id': 'id'}]}
|
||||
custom_view.filters = {}
|
||||
custom_view.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/management/form-title/shared-custom-test-view/')
|
||||
assert '<span>Number</span></th>' in resp
|
||||
|
||||
custom_view.columns = {'list': [{'id': 'unknown'}]}
|
||||
custom_view.store()
|
||||
resp = app.get('/backoffice/management/form-title/shared-custom-test-view/')
|
||||
assert '<th></th>' in resp # columns not found
|
||||
|
||||
|
||||
def test_backoffice_custom_view_sort_field(pub):
|
||||
if not pub.is_using_postgresql():
|
||||
pytest.skip('this requires SQL')
|
||||
|
|
|
@ -1796,7 +1796,7 @@ class FormPage(Directory):
|
|||
|
||||
fields.sort(key=field_position)
|
||||
|
||||
if not fields:
|
||||
if not fields and not ignore_form:
|
||||
return self.get_fields_from_query(ignore_form=True)
|
||||
|
||||
return fields
|
||||
|
|
Loading…
Reference in New Issue