@ -2,8 +2,9 @@ import importlib
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from rest_framework import viewsets
|
||||
from rest_framework_json_api.metadata import JSONAPIMetadata
|
||||
from rest_framework.exceptions import APIException
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.permissions import IsAuthenticated, IsAuthenticatedOrReadOnly
|
||||
from rest_framework.response import Response
|
||||
|
||||
from access.mixins.organization import OrganizationMixin
|
||||
@ -764,6 +765,17 @@ class ReadOnlyModelViewSet(
|
||||
|
||||
|
||||
|
||||
class ReadOnlyListModelViewSet(
|
||||
ModelViewSetBase,
|
||||
List,
|
||||
viewsets.GenericViewSet,
|
||||
):
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class AuthUserReadOnlyModelViewSet(
|
||||
ReadOnlyModelViewSet
|
||||
):
|
||||
@ -789,3 +801,24 @@ class IndexViewset(
|
||||
IsAuthenticated,
|
||||
]
|
||||
|
||||
|
||||
class PublicReadOnlyViewSet(
|
||||
ReadOnlyListModelViewSet
|
||||
):
|
||||
"""Public Viewable ViewSet
|
||||
|
||||
User does not need to be authenticated. This viewset is intended to be
|
||||
inherited by viewsets that are intended to be consumed by unauthenticated
|
||||
public users.
|
||||
|
||||
URL **must** be prefixed with `public`
|
||||
|
||||
Args:
|
||||
ReadOnlyModelViewSet (ViewSet): Common Read-Only Viewset
|
||||
"""
|
||||
|
||||
permission_classes = [
|
||||
IsAuthenticatedOrReadOnly,
|
||||
]
|
||||
|
||||
metadata_class = JSONAPIMetadata
|
Reference in New Issue
Block a user