wcs: filter_by_user with nameid as value (#76604)
gitea/publik-django-templatetags/pipeline/head This commit looks good
Details
gitea/publik-django-templatetags/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b41e397d02
commit
c1e3cba42f
|
@ -190,8 +190,12 @@ class LazyCardDefObjectsManager:
|
|||
|
||||
def filter_by_user(self, user, op='eq'):
|
||||
qs = self._clone()
|
||||
if user and user.is_authenticated and user.get_name_id():
|
||||
qs._filters['filter-user-uuid'] = user.get_name_id()
|
||||
if user:
|
||||
if hasattr(user, 'is_authenticated') and hasattr(user, 'get_name_id'):
|
||||
if user.is_authenticated and user.get_name_id():
|
||||
qs._filters['filter-user-uuid'] = user.get_name_id()
|
||||
elif isinstance(user, str):
|
||||
qs._filters['filter-user-uuid'] = user
|
||||
return qs
|
||||
|
||||
def filter_by_status(self, status, op='eq'):
|
||||
|
|
|
@ -481,6 +481,7 @@ def test_filter_by_number(mock_send, context, nocache):
|
|||
|
||||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_filter_by_user(mock_send, context, nocache):
|
||||
context['nameid'] = 'zyx'
|
||||
for tpl in ['filter_by_user', 'filter_by:"user"|filter_value']:
|
||||
t = Template('{{ cards|objects:"foo"|%s:request.user|list }}' % tpl)
|
||||
mock_send.reset_mock()
|
||||
|
@ -503,6 +504,11 @@ def test_filter_by_user(mock_send, context, nocache):
|
|||
t.render(context)
|
||||
assert 'filter-user-uuid=xyz&' in mock_send.call_args_list[0][0][0].url
|
||||
|
||||
t = Template('{{ cards|objects:"foo"|%s:nameid|list }}' % tpl)
|
||||
mock_send.reset_mock()
|
||||
t.render(context)
|
||||
assert 'filter-user-uuid=zyx&' in mock_send.call_args_list[0][0][0].url
|
||||
|
||||
for filter_op, api_op in OPERATORS:
|
||||
mock_send.reset_mock()
|
||||
t = Template(
|
||||
|
|
Loading…
Reference in New Issue