feat(devops): public feature flag endpoint pagination limited to 20 results
ref: #673 closes #663
This commit is contained in:
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -20,5 +20,4 @@
|
||||
"cSpell.language": "en-AU",
|
||||
"jest.enable": false,
|
||||
"pylint.enabled": true,
|
||||
"pylint.importStrategy": "fromEnvironment",
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import importlib
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from rest_framework import viewsets
|
||||
from rest_framework import viewsets, pagination
|
||||
from rest_framework_json_api.metadata import JSONAPIMetadata
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.permissions import IsAuthenticated, IsAuthenticatedOrReadOnly
|
||||
@ -802,6 +802,20 @@ class IndexViewset(
|
||||
]
|
||||
|
||||
|
||||
class StaticPageNumbering(
|
||||
pagination.PageNumberPagination
|
||||
):
|
||||
"""Enforce Page Numbering
|
||||
|
||||
Enfore results per page min/max to static value that cant be changed.
|
||||
"""
|
||||
|
||||
page_size = 20
|
||||
|
||||
max_page_size = 20
|
||||
|
||||
|
||||
|
||||
class PublicReadOnlyViewSet(
|
||||
ReadOnlyListModelViewSet
|
||||
):
|
||||
@ -817,6 +831,8 @@ class PublicReadOnlyViewSet(
|
||||
ReadOnlyModelViewSet (ViewSet): Common Read-Only Viewset
|
||||
"""
|
||||
|
||||
pagination_class = StaticPageNumbering
|
||||
|
||||
permission_classes = [
|
||||
IsAuthenticatedOrReadOnly,
|
||||
]
|
||||
|
@ -8,7 +8,8 @@ from rest_framework.reverse import reverse
|
||||
from access.models.organization import Organization
|
||||
|
||||
from api.tests.abstract.viewsets import ViewSetModel
|
||||
from api.viewsets.common import PublicReadOnlyViewSet
|
||||
from api.viewsets.common import PublicReadOnlyViewSet, StaticPageNumbering
|
||||
|
||||
|
||||
from devops.models.software_enable_feature_flag import SoftwareEnableFeatureFlag
|
||||
from devops.viewsets.public_feature_flag import ViewSet
|
||||
@ -115,3 +116,14 @@ class ViewsetList(
|
||||
view_set = self.viewset()
|
||||
|
||||
assert view_set.metadata_class is JSONAPIMetadata
|
||||
|
||||
|
||||
def test_view_attr_pagination_class_value(self):
|
||||
"""Attribute Test
|
||||
|
||||
Attribute `pagination_class` must be metadata class `StaticPageNumbering`
|
||||
"""
|
||||
|
||||
view_set = self.viewset()
|
||||
|
||||
assert view_set.pagination_class is StaticPageNumbering
|
||||
|
Reference in New Issue
Block a user