Skip to content

Commit e9a68e5

Browse files
authored
Merge pull request #1 from tdruez/master
Fixed Permissions.get_required_object_permissions for #4927
2 parents c30ccac + 06a1e12 commit e9a68e5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rest_framework/permissions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from django.http import Http404
77

8+
from rest_framework import exceptions
89
from rest_framework.compat import is_authenticated
910

1011

@@ -108,6 +109,10 @@ def get_required_permissions(self, method, model_cls):
108109
'app_label': model_cls._meta.app_label,
109110
'model_name': model_cls._meta.model_name
110111
}
112+
113+
if method not in self.perms_map:
114+
raise exceptions.MethodNotAllowed(method)
115+
111116
return [perm % kwargs for perm in self.perms_map[method]]
112117

113118
def has_permission(self, request, view):
@@ -169,6 +174,10 @@ def get_required_object_permissions(self, method, model_cls):
169174
'app_label': model_cls._meta.app_label,
170175
'model_name': model_cls._meta.model_name
171176
}
177+
178+
if method not in self.perms_map:
179+
raise exceptions.MethodNotAllowed(method)
180+
172181
return [perm % kwargs for perm in self.perms_map[method]]
173182

174183
def has_object_permission(self, request, view, obj):

0 commit comments

Comments
 (0)