diff --git a/chord_metadata_service/authz/viewset.py b/chord_metadata_service/authz/viewset.py index 458cf7bda..883af5aa5 100644 --- a/chord_metadata_service/authz/viewset.py +++ b/chord_metadata_service/authz/viewset.py @@ -10,12 +10,12 @@ from .permissions import BentoDataTypePermission __all__ = [ - "BentoAuthzScopedModelGenericViewSet", + "BentoAuthzScopedModelGenericListViewSet", "BentoAuthzScopedModelViewSet", ] -class BentoAuthzScopedModelGenericViewSet(viewsets.GenericViewSet): +class BentoAuthzScopedModelGenericListViewSet(viewsets.GenericViewSet, mixins.ListModelMixin): """ An extension of the DRF generic viewset which adds utility functions for Bento Django permissions classes. These work together to properly implement scoped Bento permissions based on the request being made. @@ -67,8 +67,7 @@ class BentoAuthzScopedModelViewSet( mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, - mixins.ListModelMixin, - BentoAuthzScopedModelGenericViewSet + BentoAuthzScopedModelGenericListViewSet ): """ This class is equivalent to the DRF viewsets.ModelViewSet class, except with our BentoAuthzModelGenericViewSet diff --git a/chord_metadata_service/experiments/api_views.py b/chord_metadata_service/experiments/api_views.py index 2b0ecdd6c..de69dd253 100644 --- a/chord_metadata_service/experiments/api_views.py +++ b/chord_metadata_service/experiments/api_views.py @@ -2,14 +2,14 @@ from bento_lib.auth.permissions import P_QUERY_DATA from django_filters.rest_framework import DjangoFilterBackend from drf_spectacular.utils import extend_schema, inline_serializer -from rest_framework import mixins, serializers, status +from rest_framework import serializers, status from rest_framework.settings import api_settings from rest_framework.decorators import api_view, permission_classes from rest_framework.request import Request as DrfRequest from rest_framework.response import Response from chord_metadata_service.authz.permissions import BentoAllowAny -from chord_metadata_service.authz.viewset import BentoAuthzScopedModelViewSet, BentoAuthzScopedModelGenericViewSet +from chord_metadata_service.authz.viewset import BentoAuthzScopedModelViewSet, BentoAuthzScopedModelGenericListViewSet from chord_metadata_service.chord.data_types import DATA_TYPE_EXPERIMENT from chord_metadata_service.discovery.scope import get_request_discovery_scope from chord_metadata_service.restapi.api_renderers import ( @@ -72,7 +72,7 @@ async def get_queryset(self): ) -class ExperimentBatchViewSet(mixins.ListModelMixin, BentoAuthzScopedModelGenericViewSet): +class ExperimentBatchViewSet(BentoAuthzScopedModelGenericListViewSet): """ get: Return a list of all existing experiments diff --git a/chord_metadata_service/patients/api_views.py b/chord_metadata_service/patients/api_views.py index a2ce8daef..d18769070 100644 --- a/chord_metadata_service/patients/api_views.py +++ b/chord_metadata_service/patients/api_views.py @@ -14,14 +14,14 @@ from django.http.request import QueryDict from django_filters.rest_framework import DjangoFilterBackend from drf_spectacular.utils import extend_schema, inline_serializer -from rest_framework import filters, mixins, serializers, status +from rest_framework import filters, serializers, status from rest_framework.decorators import action from rest_framework.request import Request as DrfRequest from rest_framework.response import Response from rest_framework.settings import api_settings from chord_metadata_service.authz.middleware import authz_middleware -from chord_metadata_service.authz.viewset import BentoAuthzScopedModelViewSet, BentoAuthzScopedModelGenericViewSet +from chord_metadata_service.authz.viewset import BentoAuthzScopedModelViewSet, BentoAuthzScopedModelGenericListViewSet from chord_metadata_service.authz.types import DataTypeDiscoveryPermissions from chord_metadata_service.chord import data_types as dts from chord_metadata_service.discovery import responses as dres @@ -167,7 +167,7 @@ def phenopackets(self, request: DrfRequest, *_args, **_kwargs): ) -class IndividualBatchViewSet(mixins.ListModelMixin, BentoAuthzScopedModelGenericViewSet): +class IndividualBatchViewSet(BentoAuthzScopedModelGenericListViewSet): serializer_class = IndividualSerializer pagination_class = BatchResultsSetPagination diff --git a/chord_metadata_service/phenopackets/api_views.py b/chord_metadata_service/phenopackets/api_views.py index fe96c693c..964a2f823 100644 --- a/chord_metadata_service/phenopackets/api_views.py +++ b/chord_metadata_service/phenopackets/api_views.py @@ -2,14 +2,14 @@ from bento_lib.auth.permissions import P_QUERY_DATA from django_filters.rest_framework import DjangoFilterBackend from drf_spectacular.utils import extend_schema, inline_serializer -from rest_framework import mixins, serializers, status +from rest_framework import serializers, status from rest_framework.settings import api_settings from rest_framework.decorators import api_view, permission_classes from rest_framework.request import Request as DrfRequest from rest_framework.response import Response from chord_metadata_service.authz.permissions import BentoAllowAny -from chord_metadata_service.authz.viewset import BentoAuthzScopedModelViewSet, BentoAuthzScopedModelGenericViewSet +from chord_metadata_service.authz.viewset import BentoAuthzScopedModelViewSet, BentoAuthzScopedModelGenericListViewSet from chord_metadata_service.chord.data_types import DATA_TYPE_PHENOPACKET from chord_metadata_service.discovery.scope import get_request_discovery_scope from chord_metadata_service.restapi.api_renderers import ( @@ -62,10 +62,7 @@ async def get_queryset(self): ) -class BiosampleBatchViewSet( - mixins.ListModelMixin, - BentoAuthzScopedModelGenericViewSet, -): +class BiosampleBatchViewSet(BentoAuthzScopedModelGenericListViewSet): """ get: Return a list of all existing biosamples