Files
Tablequizwiki/lib/api/permissions.py

12 lines
358 B
Python
Raw Permalink Normal View History

from rest_framework import permissions
class IsAuthorOrReadOnly(permissions.BasePermission):
def has_object_permission(self, request, view, obj):
# Read permissions are allowed to any request
if request.method in permissions.SAFE_METHODS:
return True
return obj.author == request.user or request.user.is_superuser