Skip to content

Instantly share code, notes, and snippets.

@evgeni
Last active May 20, 2017 10:49
Show Gist options
  • Save evgeni/357918223d418025be1da967774acec5 to your computer and use it in GitHub Desktop.
Save evgeni/357918223d418025be1da967774acec5 to your computer and use it in GitHub Desktop.
from rest_framework import permissions
class IsAuthenticatedDD(permissions.BasePermission):
"""
Allows access only to authenticated users who are DDs.
Based on IsAuthenticated
https://github.com/encode/django-rest-framework/blob/master/rest_framework/permissions.py#L44
"""
def has_permission(self, request, view):
return request.user and is_authenticated(request.user) and request.user.is_dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment