1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #8499: Content types REST API endpoint should not require model permission

This commit is contained in:
jeremystretch
2022-02-01 15:14:13 -05:00
parent dd71942a5e
commit 3bb7184f28
3 changed files with 3 additions and 2 deletions

View File

@ -16,6 +16,7 @@
* [#8377](https://github.com/netbox-community/netbox/issues/8377) - Fix calculation of absolute cable lengths when specified in fractional units * [#8377](https://github.com/netbox-community/netbox/issues/8377) - Fix calculation of absolute cable lengths when specified in fractional units
* [#8456](https://github.com/netbox-community/netbox/issues/8456) - Fix redundant display of VRF RD in prefix view * [#8456](https://github.com/netbox-community/netbox/issues/8456) - Fix redundant display of VRF RD in prefix view
* [#8465](https://github.com/netbox-community/netbox/issues/8465) - Accept empty string values for Interface `rf_channel` in REST API * [#8465](https://github.com/netbox-community/netbox/issues/8465) - Accept empty string values for Interface `rf_channel` in REST API
* [#8499](https://github.com/netbox-community/netbox/issues/8499) - Content types REST API endpoint should not require model permission
--- ---

View File

@ -4,6 +4,7 @@ from django_rq.queues import get_connection
from rest_framework import status from rest_framework import status
from rest_framework.decorators import action from rest_framework.decorators import action
from rest_framework.exceptions import PermissionDenied from rest_framework.exceptions import PermissionDenied
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.routers import APIRootView from rest_framework.routers import APIRootView
from rest_framework.viewsets import ReadOnlyModelViewSet, ViewSet from rest_framework.viewsets import ReadOnlyModelViewSet, ViewSet
@ -382,6 +383,7 @@ class ContentTypeViewSet(ReadOnlyModelViewSet):
""" """
Read-only list of ContentTypes. Limit results to ContentTypes pertinent to NetBox objects. Read-only list of ContentTypes. Limit results to ContentTypes pertinent to NetBox objects.
""" """
permission_classes = (IsAuthenticated,)
queryset = ContentType.objects.order_by('app_label', 'model') queryset = ContentType.objects.order_by('app_label', 'model')
serializer_class = serializers.ContentTypeSerializer serializer_class = serializers.ContentTypeSerializer
filterset_class = filtersets.ContentTypeFilterSet filterset_class = filtersets.ContentTypeFilterSet

View File

@ -608,7 +608,6 @@ class CreatedUpdatedFilterTest(APITestCase):
class ContentTypeTest(APITestCase): class ContentTypeTest(APITestCase):
@override_settings(EXEMPT_VIEW_PERMISSIONS=['contenttypes.contenttype'])
def test_list_objects(self): def test_list_objects(self):
contenttype_count = ContentType.objects.count() contenttype_count = ContentType.objects.count()
@ -616,7 +615,6 @@ class ContentTypeTest(APITestCase):
self.assertHttpStatus(response, status.HTTP_200_OK) self.assertHttpStatus(response, status.HTTP_200_OK)
self.assertEqual(response.data['count'], contenttype_count) self.assertEqual(response.data['count'], contenttype_count)
@override_settings(EXEMPT_VIEW_PERMISSIONS=['contenttypes.contenttype'])
def test_get_object(self): def test_get_object(self):
contenttype = ContentType.objects.first() contenttype = ContentType.objects.first()