data: fix condition with AttributeError (#68865)
gitea-wip/combo/pipeline/head Build started... Details
gitea/combo/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Lauréline Guérin 2022-09-08 22:03:42 +02:00
parent c43d003e54
commit 29e4f084d3
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 7 additions and 1 deletions

View File

@ -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):

View File

@ -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):