-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ Disable pagination when requesting form definitions in the admin
- Loading branch information
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from rest_framework import pagination | ||
|
||
|
||
class FormDefinitionPagination(pagination.PageNumberPagination): | ||
"""A page number pagination that will be disabled if the specific query parameter | ||
for page size is set to 0. | ||
""" | ||
|
||
page_size = 25 | ||
page_size_query_param = "page_size" | ||
max_page_size = None | ||
|
||
def get_page_size(self, request) -> int | None: | ||
if ( | ||
self.page_size_query_param | ||
and request.query_params.get(self.page_query_param) == 0 | ||
): | ||
return None | ||
return super().get_page_size(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters