Skip to content
Snippets Groups Projects

Refactor update creation api

Merged Samuel GAIST requested to merge refactor_update_creation_api into master
All threads resolved!
1 file
+ 9
4
Compare changes
  • Side-by-side
  • Inline
@@ -27,21 +27,26 @@
from rest_framework import permissions
class IsSuperuser(permissions.BasePermission):
"""
Global permission check for super user
"""
def has_permission(self, request, view):
return request.user.is_superuser
class IsAuthor(permissions.BasePermission):
class IsAuthor(permissions.IsAuthenticated):
"""
Global permission check that verify if the user
is also the onwer of the asked data
"""
def has_permission(self, request, view):
kwargs = request.parser_context.get('kwargs')
author_name = kwargs.get('author_name')
return request.user.username == author_name
allowed = super().has_permission(request, view)
if allowed:
kwargs = request.parser_context.get("kwargs")
author_name = kwargs.get("author_name")
allowed = request.user.username == author_name
return allowed
Loading