Skip to content

Commit

Permalink
feat: add pagination to the support tool customer list (#2252)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinan029 authored Sep 26, 2024
1 parent f0d2b3c commit fb8f364
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased

[4.25.17]
---------
* feat: add pagination to the support tool customer list

[4.25.16]
---------
* feat: add a waffle flag for enterprise groups v2 feature
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.25.16"
__version__ = "4.25.17"
11 changes: 8 additions & 3 deletions enterprise/api/v1/views/enterprise_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,22 @@ def basic_list(self, request, *arg, **kwargs):
# pylint: disable=unused-argument
def support_tool(self, request, *arg, **kwargs):
"""
Enterprise Customer's detail data for the support tool
Enterprise Customer's detail data with pagination for the support tool
Supported query param:
- uuid: filter the enterprise customer uuid .
- user_query: filter the enterprise customer name.
"""
enterprise_uuid = request.GET.get('uuid')
user_query = request.GET.get("user_query", None)
queryset = self.get_queryset().order_by('name')
if user_query:
queryset = queryset.filter(Q(slug__icontains=user_query) | Q(name__icontains=user_query))
if enterprise_uuid:
queryset = queryset.filter(uuid=enterprise_uuid)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
page = self.paginate_queryset(queryset)
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)

@has_any_permissions('enterprise.can_access_admin_dashboard',
ENTERPRISE_CUSTOMER_PROVISIONING_ADMIN_ACCESS_PERMISSION)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ def test_enterprise_customer_support_tool(
self.create_items(factory, model_items)
response = self.client.get(settings.TEST_SERVER + url)
response = self.load_json(response.content)
assert sorted(expected_json, key=sorting_key) == sorted(response, key=sorting_key)
assert sorted(expected_json, key=sorting_key) == sorted(response['results'], key=sorting_key)

@ddt.data(
# Request missing required permissions query param.
Expand Down

0 comments on commit fb8f364

Please sign in to comment.