"""
`DRF viewsets <https://www.django-rest-framework.org/api-guide/viewsets/>`__
"""
from rest_framework import mixins, viewsets
from .throttling import (
DELETEModelUserRateThrottle,
PATCHModelUserRateThrottle,
POSTModelUserRateThrottle,
)
[docs]class ReadOnlyViewSet(
viewsets.ReadOnlyModelViewSet,
):
"""
Only ``list()`` and ``retrieve()`` actions.
"""
[docs]class CreateOnlyViewSet(
mixins.CreateModelMixin,
viewsets.GenericViewSet,
):
"""
Only ``create()`` action.
"""
throttle_classes = [
POSTModelUserRateThrottle,
]
[docs]class ListAndDeleteOnlyViewSet(
mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet
):
"""
Only ``list()`` and ``destroy()`` actions.
"""
throttle_classes = [
DELETEModelUserRateThrottle,
]
[docs]class ReadAndDeleteOnlyViewSet(
mixins.DestroyModelMixin,
viewsets.ReadOnlyModelViewSet,
):
"""
Only ``list()``, ``retrieve()``, and ``destroy()`` actions.
"""
throttle_classes = [
DELETEModelUserRateThrottle,
]
[docs]class ReadDeleteCreateOnlyViewSet(
mixins.DestroyModelMixin,
mixins.CreateModelMixin,
viewsets.ReadOnlyModelViewSet,
):
"""
Only ``list()``, ``retrieve()``, ``destroy()`` and ``create()`` actions.
"""
throttle_classes = [
POSTModelUserRateThrottle,
DELETEModelUserRateThrottle,
]
[docs]class ReadUpdateCreateOnlyViewSet(
mixins.UpdateModelMixin, mixins.CreateModelMixin, viewsets.ReadOnlyModelViewSet
):
throttle_classes = [
POSTModelUserRateThrottle,
PATCHModelUserRateThrottle,
]