publik: fix get filter called on LazyCardDef (#88578)
gitea/publik-django-templatetags/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2024-04-03 15:42:14 +02:00
parent 6ad1cc0911
commit e68e6e7ff9
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 7 additions and 0 deletions

View File

@ -40,6 +40,8 @@ def get(obj, key):
return obj[key]
except (IndexError, KeyError, TypeError):
return None
except TypeError:
return None
@register.filter

View File

@ -112,6 +112,11 @@ def test_objects(mock_send, settings, context, nocache):
t.render(context)
assert mock_send.call_args_list[0][0][0].url.startswith('http://127.0.0.3:8999/api/cards/bar/list?')
mock_send.reset_mock()
t = Template('{{ cards|get:"bar" }}')
t.render(context)
assert mock_send.call_args_list == []
context = Context({}) # no cards in context
mock_send.reset_mock()
t = Template('{{ cards|objects:"bar" }}')