mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
simplify argument handling
This commit is contained in:
parent
9ea615af14
commit
9a9a00bff2
|
@ -140,9 +140,7 @@ class APIView(View):
|
|||
"""
|
||||
if not request.successful_authenticator:
|
||||
raise exceptions.NotAuthenticated()
|
||||
if message is not None:
|
||||
raise exceptions.PermissionDenied(message)
|
||||
raise exceptions.PermissionDenied()
|
||||
raise exceptions.PermissionDenied(detail=message)
|
||||
|
||||
def throttled(self, request, wait):
|
||||
"""
|
||||
|
@ -282,9 +280,9 @@ class APIView(View):
|
|||
"""
|
||||
for permission in self.get_permissions():
|
||||
if not permission.has_permission(request, self):
|
||||
if hasattr(permission, 'message'):
|
||||
self.permission_denied(request, permission.message)
|
||||
self.permission_denied(request)
|
||||
self.permission_denied(
|
||||
request, message=getattr(permission, 'message', None)
|
||||
)
|
||||
|
||||
def check_object_permissions(self, request, obj):
|
||||
"""
|
||||
|
@ -293,9 +291,9 @@ class APIView(View):
|
|||
"""
|
||||
for permission in self.get_permissions():
|
||||
if not permission.has_object_permission(request, self, obj):
|
||||
if hasattr(permission, 'message'):
|
||||
self.permission_denied(request, permission.message)
|
||||
self.permission_denied(request)
|
||||
self.permission_denied(
|
||||
request, message=getattr(permission, 'message', None)
|
||||
)
|
||||
|
||||
def check_throttles(self, request):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user