data: fix condition with AttributeError (#68865)
This commit is contained in:
parent
c43d003e54
commit
29e4f084d3
|
@ -1359,7 +1359,7 @@ class CellBase(models.Model, metaclass=CellMeta):
|
|||
context.push(original_context)
|
||||
try:
|
||||
return Template('{%% if %s %%}OK{%% endif %%}' % condition).render(context) == 'OK'
|
||||
except (TemplateSyntaxError, VariableDoesNotExist):
|
||||
except (AttributeError, TemplateSyntaxError, VariableDoesNotExist):
|
||||
return False
|
||||
|
||||
def is_visible(self, request, context=None, check_validity_info=True):
|
||||
|
|
|
@ -2953,6 +2953,12 @@ def test_cell_condition(mock_send, nocache, app):
|
|||
resp = app.get(page.get_online_url())
|
||||
assert len(resp.context['cells']) == 1
|
||||
|
||||
# wrong condition
|
||||
cell.condition = 'cards|objects:"card_model_1"|first|filter_by:"fielda"|filter_value:"foo"'
|
||||
cell.save()
|
||||
resp = app.get(page.get_online_url())
|
||||
assert len(resp.context.get('cells') or []) == 0
|
||||
|
||||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_card_file_redirection(mock_send, app):
|
||||
|
|
Loading…
Reference in New Issue