mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 04:58:16 -06:00
Remove BriefModeMixin
This commit is contained in:
parent
3b0f9bbefb
commit
2748a5c28f
@ -34,6 +34,8 @@ class BaseViewSet(GenericViewSet):
|
||||
"""
|
||||
Base class for all API ViewSets. This is responsible for the enforcement of object-based permissions.
|
||||
"""
|
||||
brief = False
|
||||
|
||||
def initial(self, request, *args, **kwargs):
|
||||
super().initial(request, *args, **kwargs)
|
||||
|
||||
@ -42,6 +44,13 @@ class BaseViewSet(GenericViewSet):
|
||||
if action := HTTP_ACTIONS[request.method]:
|
||||
self.queryset = self.queryset.restrict(request.user, action)
|
||||
|
||||
def initialize_request(self, request, *args, **kwargs):
|
||||
|
||||
# Annotate whether brief mode is active
|
||||
self.brief = request.method == 'GET' and request.GET.get('brief')
|
||||
|
||||
return super().initialize_request(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
serializer_class = self.get_serializer_class()
|
||||
@ -77,7 +86,6 @@ class BaseViewSet(GenericViewSet):
|
||||
|
||||
|
||||
class NetBoxReadOnlyModelViewSet(
|
||||
mixins.BriefModeMixin,
|
||||
mixins.CustomFieldsMixin,
|
||||
mixins.ExportTemplatesMixin,
|
||||
drf_mixins.RetrieveModelMixin,
|
||||
@ -91,7 +99,6 @@ class NetBoxModelViewSet(
|
||||
mixins.BulkUpdateModelMixin,
|
||||
mixins.BulkDestroyModelMixin,
|
||||
mixins.ObjectValidationMixin,
|
||||
mixins.BriefModeMixin,
|
||||
mixins.CustomFieldsMixin,
|
||||
mixins.ExportTemplatesMixin,
|
||||
drf_mixins.CreateModelMixin,
|
||||
|
@ -9,7 +9,6 @@ from extras.models import ExportTemplate
|
||||
from netbox.api.serializers import BulkOperationSerializer
|
||||
|
||||
__all__ = (
|
||||
'BriefModeMixin',
|
||||
'BulkDestroyModelMixin',
|
||||
'BulkUpdateModelMixin',
|
||||
'CustomFieldsMixin',
|
||||
@ -19,20 +18,6 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class BriefModeMixin:
|
||||
"""
|
||||
Enables brief mode support, so that the client can invoke a model's nested serializer by passing e.g.
|
||||
GET /api/dcim/sites/?brief=True
|
||||
"""
|
||||
brief = False
|
||||
|
||||
def initialize_request(self, request, *args, **kwargs):
|
||||
# Annotate whether brief mode is active
|
||||
self.brief = request.method == 'GET' and request.GET.get('brief')
|
||||
|
||||
return super().initialize_request(request, *args, **kwargs)
|
||||
|
||||
|
||||
class CustomFieldsMixin:
|
||||
"""
|
||||
For models which support custom fields, populate the `custom_fields` context.
|
||||
|
Loading…
Reference in New Issue
Block a user