[Patchew-devel] [PATCH] rest: allow IsMaintainerOrReadOnly that applies to Message

Paolo Bonzini posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180404165410.27070-1-pbonzini@redhat.com
api/rest.py | 2 ++
1 file changed, 2 insertions(+)
[Patchew-devel] [PATCH] rest: allow IsMaintainerOrReadOnly that applies to Message
Posted by Paolo Bonzini 6 years ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	I had to apply this for Shubham's patch to allow non-administrator
	access.

 api/rest.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/api/rest.py b/api/rest.py
index bb56b4b..3e0cbc3 100644
--- a/api/rest.py
+++ b/api/rest.py
@@ -41,6 +41,8 @@ class IsMaintainerOrReadOnly(permissions.BasePermission):
     Allows access only to admin users or maintainers.
     """
     def has_object_permission(self, request, view, obj):
+        if isinstance(obj, Message):
+            obj = obj.project
         return request.method in permissions.SAFE_METHODS or \
                obj.maintained_by(request.user)
 
-- 
2.16.2

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel