misc: report an error on unknown custom view (#88535) #1302
|
@ -2241,10 +2241,15 @@ def test_lazy_global_forms(pub):
|
|||
)
|
||||
assert tmpl.render(context) == '7,8,9,10,'
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
tmpl = Template('{{forms|objects:"foobarlazy"|with_custom_view:"private-form-view"|count}}')
|
||||
assert tmpl.render(context) == '0'
|
||||
assert [x.summary for x in pub.loggederror_class.select()] == ['Unknown custom view "private-form-view"']
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
tmpl = Template('{{forms|objects:"foobarlazy"|with_custom_view:"unknown"|count}}')
|
||||
assert tmpl.render(context) == '0'
|
||||
assert [x.summary for x in pub.loggederror_class.select()] == ['Unknown custom view "unknown"']
|
||||
|
||||
custom_view4 = pub.custom_view_class()
|
||||
custom_view4.title = 'unknown filter'
|
||||
|
@ -2253,6 +2258,8 @@ def test_lazy_global_forms(pub):
|
|||
custom_view4.filters = {'filter-42': 'on', 'filter-42-value': 'foo', 'filter-foobar': 'baz'}
|
||||
custom_view4.visibility = 'any'
|
||||
custom_view4.store()
|
||||
|
||||
pub.loggederror_class.wipe()
|
||||
tmpl = Template('{{forms|objects:"foobarlazy"|with_custom_view:"unknown-filter"|count}}')
|
||||
assert tmpl.render(context) == '0'
|
||||
assert pub.loggederror_class.count() == 2
|
||||
|
|
|
@ -176,6 +176,7 @@ class LazyFormDefObjectsManager:
|
|||
try:
|
||||
custom_view = get_publisher().custom_view_class.select(lookup_criterias)[0]
|
||||
except IndexError:
|
||||
self.report_error(_('Unknown custom view "%(slug)s"') % {'slug': custom_view_slug})
|
||||
return self.none()
|
||||
return self._clone(self._criterias + custom_view.get_criterias(), order_by=custom_view.order_by)
|
||||
|
||||
|
|
Loading…
Reference in New Issue