Created
January 23, 2013 15:21
-
-
Save tomchristie/4608048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IsOwner(permissions.BasePermission): | |
""" | |
Custom permission to only allow owners of an object to edit it. | |
""" | |
def has_permission(self, request, view, obj=None): | |
# Skip the check unless this is an object-level test | |
if obj is None: | |
return True | |
# Write permissions are only allowed to the owner of the snippet | |
return obj.owner == request.user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment