mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Fixed Permissions.get_required_object_permissions for #4927
This commit is contained in:
parent
b936d829a6
commit
06a1e12fd8
|
@ -5,6 +5,7 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.http import Http404
|
||||
|
||||
from rest_framework import exceptions
|
||||
from rest_framework.compat import is_authenticated
|
||||
|
||||
|
||||
|
@ -108,6 +109,10 @@ class DjangoModelPermissions(BasePermission):
|
|||
'app_label': model_cls._meta.app_label,
|
||||
'model_name': model_cls._meta.model_name
|
||||
}
|
||||
|
||||
if method not in self.perms_map:
|
||||
raise exceptions.MethodNotAllowed(method)
|
||||
|
||||
return [perm % kwargs for perm in self.perms_map[method]]
|
||||
|
||||
def has_permission(self, request, view):
|
||||
|
@ -169,6 +174,10 @@ class DjangoObjectPermissions(DjangoModelPermissions):
|
|||
'app_label': model_cls._meta.app_label,
|
||||
'model_name': model_cls._meta.model_name
|
||||
}
|
||||
|
||||
if method not in self.perms_map:
|
||||
raise exceptions.MethodNotAllowed(method)
|
||||
|
||||
return [perm % kwargs for perm in self.perms_map[method]]
|
||||
|
||||
def has_object_permission(self, request, view, obj):
|
||||
|
|
Loading…
Reference in New Issue
Block a user