from rest_framework.permissions import BasePermission


class ObjectHasTokenUser(BasePermission):
    """
    The object's user matches the token's user.
    """
    def has_object_permission(self, request, view, obj):
        token = request.auth

        if not token:
            return False

        if not hasattr(token, 'scope'):
            assert False, ('TokenHasReadWriteScope requires the'
                           '`OAuth2Authentication` authentication '
                           'class to be used.')

        if hasattr(obj, 'user'):
            print 'token.user', token.user
            print 'obj.user', obj.user

            return token.user == obj.user

from rest_framework.permissions import BasePermission


class ObjectHasTokenUser(BasePermission):
    """
    The object's user matches the token's user.
    """
    def has_object_permission(self, request, view, obj):
        token = request.auth

        if not token:
            return False

        if not hasattr(token, 'scope'):
            assert False, ('ObjectHasTokenUser requires the'
                           '`OAuth2Authentication` authentication '
                           'class to be used.')

        if hasattr(obj, 'user'):
            return token.user == obj.user

Remove debugging code, fix typo
Remove debugging code, fix typo

  from rest_framework.permissions import BasePermission
  
  
  class ObjectHasTokenUser(BasePermission):
      """
      The object's user matches the token's user.
      """
      def has_object_permission(self, request, view, obj):
          token = request.auth
  
          if not token:
              return False
  
          if not hasattr(token, 'scope'):
-             assert False, ('TokenHasReadWriteScope requires the'
+             assert False, ('ObjectHasTokenUser requires the'
                             '`OAuth2Authentication` authentication '
                             'class to be used.')
  
          if hasattr(obj, 'user'):
-             print 'token.user', token.user
-             print 'obj.user', obj.user
- 
              return token.user == obj.user
  
Remove debugging code, fix typo
## Code Before:
from rest_framework.permissions import BasePermission


class ObjectHasTokenUser(BasePermission):
    """
    The object's user matches the token's user.
    """
    def has_object_permission(self, request, view, obj):
        token = request.auth

        if not token:
            return False

        if not hasattr(token, 'scope'):
            assert False, ('TokenHasReadWriteScope requires the'
                           '`OAuth2Authentication` authentication '
                           'class to be used.')

        if hasattr(obj, 'user'):
            print 'token.user', token.user
            print 'obj.user', obj.user

            return token.user == obj.user

## Instruction:
Remove debugging code, fix typo
## Code After:
from rest_framework.permissions import BasePermission


class ObjectHasTokenUser(BasePermission):
    """
    The object's user matches the token's user.
    """
    def has_object_permission(self, request, view, obj):
        token = request.auth

        if not token:
            return False

        if not hasattr(token, 'scope'):
            assert False, ('ObjectHasTokenUser requires the'
                           '`OAuth2Authentication` authentication '
                           'class to be used.')

        if hasattr(obj, 'user'):
            return token.user == obj.user
