From 696261c5f0e9471eef735a515fac77615e0e9ced Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 23 Jan 2018 23:59:00 +0800 Subject: [PATCH] actually made it work --- src/users/permissions.py | 4 ++-- src/users/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/users/permissions.py b/src/users/permissions.py index 92eea61..9c40619 100644 --- a/src/users/permissions.py +++ b/src/users/permissions.py @@ -5,6 +5,6 @@ class VerifiedUser(permissions.BasePermission): """ Custom permission to only allow verified users """ + def has_permission(self, request, view): + return request.user.profile.verified - def has_object_permission(self, request, view, obj): - return obj.verified diff --git a/src/users/views.py b/src/users/views.py index d0fdef0..9fd596c 100644 --- a/src/users/views.py +++ b/src/users/views.py @@ -170,7 +170,7 @@ class OwnMentorView(generics.RetrieveUpdateDestroyAPIView): """ View for turning mentor status on (post) and modifying all mentor fields """ - permission_classes = tuple() + permission_classes = (VerifiedUser,) serializer_class = MentorSerializer def get_object(self):