Skip to content

Commit

Permalink
refactor: Remove default pagesize override for lib
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh committed Jun 6, 2024
1 parent 19358bd commit 53c8a39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_library_validation(self):
}

@skip("This endpoint shouldn't support num_blocks and has_unpublished_*.")
@patch("openedx.core.djangoapps.content_libraries.views.LibraryRootView._DEFAULT_PAGE_SIZE", new=2)
@patch("openedx.core.djangoapps.content_libraries.views.LibraryRootView.pagination_class.page_size", new=2)
def test_list_library(self):
"""
Test the /libraries API and its pagination
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_library_blocks_studio_view(self):
assert 'resources' in fragment
assert 'Hello world!' in fragment['content']

@patch("openedx.core.djangoapps.content_libraries.views.LibraryBlocksView._DEFAULT_PAGE_SIZE", new=2)
@patch("openedx.core.djangoapps.content_libraries.views.LibraryBlocksView.pagination_class.page_size", new=2)
def test_list_library_blocks(self):
"""
Test the /libraries/{lib_key_str}/blocks API and its pagination
Expand Down
15 changes: 0 additions & 15 deletions openedx/core/djangoapps/content_libraries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ class LibraryRootView(GenericAPIView):
Views to list, search for, and create content libraries.
"""

_DEFAULT_PAGE_SIZE = 50

@apidocs.schema(
parameters=[
*LibraryApiPaginationDocs.apidoc_params,
Expand All @@ -210,9 +208,6 @@ def get(self, request):
library_type = serializer.validated_data['type']
text_search = serializer.validated_data['text_search']

# Set default page size to 50
self.pagination_class.page_size = self._DEFAULT_PAGE_SIZE

queryset = api.get_libraries_for_user(
request.user,
org=org,
Expand Down Expand Up @@ -512,8 +507,6 @@ class LibraryBlocksView(GenericAPIView):
Views to work with XBlocks in a specific content library.
"""

_DEFAULT_PAGE_SIZE = 50

@apidocs.schema(
parameters=[
*LibraryApiPaginationDocs.apidoc_params,
Expand Down Expand Up @@ -542,9 +535,6 @@ def get(self, request, lib_key_str):
api.require_permission_for_library_key(key, request.user, permissions.CAN_VIEW_THIS_CONTENT_LIBRARY)
components = api.get_library_components(key, text_search=text_search, block_types=block_types)

# Set default page size to 50
self.pagination_class.page_size = self._DEFAULT_PAGE_SIZE

paginated_xblock_metadata = [
api.LibraryXBlockMetadata.from_component(key, component)
for component in self.paginate_queryset(components)
Expand Down Expand Up @@ -753,8 +743,6 @@ class LibraryImportTaskViewSet(GenericViewSet):
Import blocks from Courseware through modulestore.
"""

_DEFAULT_PAGE_SIZE = 50

@convert_exceptions
def list(self, request, lib_key_str):
"""
Expand All @@ -769,9 +757,6 @@ def list(self, request, lib_key_str):
queryset = api.ContentLibrary.objects.get_by_key(library_key).import_tasks
result = ContentLibraryBlockImportTaskSerializer(queryset, many=True).data

# Set default page size to 50
self.pagination_class.page_size = self._DEFAULT_PAGE_SIZE

return self.get_paginated_response(
self.paginate_queryset(result)
)
Expand Down

0 comments on commit 53c8a39

Please sign in to comment.