Make get_extra_action less permissive

This commit is contained in:
Ricardo Busquet 2020-03-05 00:47:47 -05:00
parent 382e3322f1
commit db724db001
2 changed files with 3 additions and 2 deletions

View File

@ -25,11 +25,12 @@ from django.utils.decorators import classonlymethod
from django.views.decorators.csrf import csrf_exempt
from rest_framework import generics, mixins, views
from rest_framework.decorators import MethodMapper
from rest_framework.reverse import reverse
def _is_extra_action(attr):
return hasattr(attr, 'mapping')
return hasattr(attr, 'mapping') and isinstance(attr.mapping, MethodMapper)
class ViewSetMixin:

View File

@ -90,7 +90,6 @@ class ActionViewSetWithMapping(ActionViewSet):
mapper = ThingWithMapping()
router = SimpleRouter()
router.register(r'actions', ActionViewSet)
router.register(r'actions-alt', ActionViewSet, basename='actions-alt')
@ -156,6 +155,7 @@ class InitializeViewSetsTestCase(TestCase):
self.assertNotIn(attribute, dir(bare_view))
self.assertIn(attribute, dir(view))
class GetExtraActionsTests(TestCase):
def test_extra_actions(self):