Skip to content

Commit 883b530

Browse files
[ENG-8052] Fixed FilterMixin issue with multiple values of notification subscription field (#11150)
1 parent 4affd58 commit 883b530

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

api/base/filters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ class FilterMixin:
160160
LIST_FIELDS = (ser.ListField,)
161161
RELATIONSHIP_FIELDS = (RelationshipField, TargetField)
162162

163+
MULTIPLE_VALUES_FIELDS = ['_id', 'guid._id', 'journal_id', 'moderation_state', 'event_name']
164+
163165
def __init__(self, *args, **kwargs):
164166
super().__init__(*args, **kwargs)
165167
if not self.serializer_class:
@@ -292,7 +294,7 @@ def parse_query_params(self, query_params):
292294
query.get(key).update({
293295
field_name: self._parse_date_param(field, source_field_name, op, value),
294296
})
295-
elif not isinstance(value, int) and source_field_name in ['_id', 'guid._id', 'journal_id', 'moderation_state']:
297+
elif not isinstance(value, int) and source_field_name in self.MULTIPLE_VALUES_FIELDS:
296298
query.get(key).update({
297299
field_name: {
298300
'op': 'in',

api_tests/subscriptions/views/test_subscriptions_list.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ def test_cannot_post_patch_put_or_delete(self, app, url, user):
5454
assert patch_res.status_code == 405
5555
assert put_res.status_code == 405
5656
assert delete_res.status_code == 405
57+
58+
def test_multiple_values_filter(self, app, url, global_user_notification, user):
59+
res = app.get(url + '?filter[event_name]=comments,global', auth=user.auth)
60+
assert len(res.json['data']) == 2
61+
for subscription in res.json['data']:
62+
subscription['attributes']['event_name'] in ['global', 'comments']

0 commit comments

Comments
 (0)