Fixed Permissions.get_required_object_permissions for #4927

This commit is contained in:
tdruez 2017-02-28 17:51:32 +01:00 committed by GitHub
parent b936d829a6
commit 06a1e12fd8

View File

@ -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):