|
|
@@ -20,7 +20,7 @@ from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired
|
|
|
from netbox.api.metadata import ContentTypeMetadata
|
|
|
from netbox.api.pagination import StripCountAnnotationsPaginator
|
|
|
from netbox.api.renderers import TextRenderer
|
|
|
-from netbox.api.viewsets import NetBoxModelViewSet
|
|
|
+from netbox.api.viewsets import NetBoxModelViewSet, MPTTLockedMixin
|
|
|
from netbox.api.viewsets.mixins import SequentialBulkCreatesMixin
|
|
|
from netbox.constants import NESTED_SERIALIZER_PREFIX
|
|
|
from utilities.api import get_serializer_for_model
|
|
|
@@ -98,7 +98,7 @@ class PassThroughPortMixin(object):
|
|
|
# Regions
|
|
|
#
|
|
|
|
|
|
-class RegionViewSet(NetBoxModelViewSet):
|
|
|
+class RegionViewSet(MPTTLockedMixin, NetBoxModelViewSet):
|
|
|
queryset = Region.objects.add_related_count(
|
|
|
Region.objects.all(),
|
|
|
Site,
|
|
|
@@ -114,7 +114,7 @@ class RegionViewSet(NetBoxModelViewSet):
|
|
|
# Site groups
|
|
|
#
|
|
|
|
|
|
-class SiteGroupViewSet(NetBoxModelViewSet):
|
|
|
+class SiteGroupViewSet(MPTTLockedMixin, NetBoxModelViewSet):
|
|
|
queryset = SiteGroup.objects.add_related_count(
|
|
|
SiteGroup.objects.all(),
|
|
|
Site,
|
|
|
@@ -149,7 +149,7 @@ class SiteViewSet(NetBoxModelViewSet):
|
|
|
# Locations
|
|
|
#
|
|
|
|
|
|
-class LocationViewSet(NetBoxModelViewSet):
|
|
|
+class LocationViewSet(MPTTLockedMixin, NetBoxModelViewSet):
|
|
|
queryset = Location.objects.add_related_count(
|
|
|
Location.objects.add_related_count(
|
|
|
Location.objects.all(),
|
|
|
@@ -350,7 +350,7 @@ class DeviceBayTemplateViewSet(NetBoxModelViewSet):
|
|
|
filterset_class = filtersets.DeviceBayTemplateFilterSet
|
|
|
|
|
|
|
|
|
-class InventoryItemTemplateViewSet(NetBoxModelViewSet):
|
|
|
+class InventoryItemTemplateViewSet(MPTTLockedMixin, NetBoxModelViewSet):
|
|
|
queryset = InventoryItemTemplate.objects.prefetch_related('device_type__manufacturer', 'role')
|
|
|
serializer_class = serializers.InventoryItemTemplateSerializer
|
|
|
filterset_class = filtersets.InventoryItemTemplateFilterSet
|
|
|
@@ -538,7 +538,7 @@ class DeviceBayViewSet(NetBoxModelViewSet):
|
|
|
brief_prefetch_fields = ['device']
|
|
|
|
|
|
|
|
|
-class InventoryItemViewSet(NetBoxModelViewSet):
|
|
|
+class InventoryItemViewSet(MPTTLockedMixin, NetBoxModelViewSet):
|
|
|
queryset = InventoryItem.objects.prefetch_related('device', 'manufacturer', 'tags')
|
|
|
serializer_class = serializers.InventoryItemSerializer
|
|
|
filterset_class = filtersets.InventoryItemFilterSet
|