
from rest_framework import permissions


class IsSuperuserOrReadOnly(permissions.BasePermission):
    '''Allow writes if superuser, read-only otherwise.'''

    def has_permission(self, request, view):
        return (request.user.is_superuser or
                request.method in permissions.SAFE_METHODS)


class IsUserOrSuperuser(permissions.BasePermission):
    '''Accept only the users themselves or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj


class IsAdvisorOrSuperuser(permissions.BasePermission):
    '''Accept only the school's advisor or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj.advisor


class IsPostOrSuperuserOnly(permissions.BasePermission):
    '''Accept POST (create) requests, superusers-only otherwise.'''

    def has_object_permissions(self, request, view, obj):
        return request.method == 'POST' or request.user.is_superuser


from rest_framework import permissions


class IsSuperuserOrReadOnly(permissions.BasePermission):
    '''Allow writes if superuser, read-only otherwise.'''

    def has_permission(self, request, view):
        return (request.user.is_superuser or
                request.method in permissions.SAFE_METHODS)


class IsUserOrSuperuser(permissions.BasePermission):
    '''Accept only the users themselves or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj


class IsAdvisorOrSuperuser(permissions.BasePermission):
    '''Accept only the school's advisor or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj.advisor


class IsPostOrSuperuserOnly(permissions.BasePermission):
    '''Accept POST (create) requests, superusers-only otherwise.'''

    def has_permission(self, request, view):
        return request.method == 'POST' or request.user.is_superuser

Make IsPostOrSuperuserOnly a non-object-level permission.
Make IsPostOrSuperuserOnly a non-object-level permission.

  
  from rest_framework import permissions
  
  
  class IsSuperuserOrReadOnly(permissions.BasePermission):
      '''Allow writes if superuser, read-only otherwise.'''
  
      def has_permission(self, request, view):
          return (request.user.is_superuser or
                  request.method in permissions.SAFE_METHODS)
  
  
  class IsUserOrSuperuser(permissions.BasePermission):
      '''Accept only the users themselves or superusers.'''
  
      def has_object_permission(self, request, view, obj):
          return request.user.is_superuser or request.user == obj
  
  
  class IsAdvisorOrSuperuser(permissions.BasePermission):
      '''Accept only the school's advisor or superusers.'''
  
      def has_object_permission(self, request, view, obj):
          return request.user.is_superuser or request.user == obj.advisor
  
  
  class IsPostOrSuperuserOnly(permissions.BasePermission):
      '''Accept POST (create) requests, superusers-only otherwise.'''
  
-     def has_object_permissions(self, request, view, obj):
+     def has_permission(self, request, view):
          return request.method == 'POST' or request.user.is_superuser
  
Make IsPostOrSuperuserOnly a non-object-level permission.
## Code Before:

from rest_framework import permissions


class IsSuperuserOrReadOnly(permissions.BasePermission):
    '''Allow writes if superuser, read-only otherwise.'''

    def has_permission(self, request, view):
        return (request.user.is_superuser or
                request.method in permissions.SAFE_METHODS)


class IsUserOrSuperuser(permissions.BasePermission):
    '''Accept only the users themselves or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj


class IsAdvisorOrSuperuser(permissions.BasePermission):
    '''Accept only the school's advisor or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj.advisor


class IsPostOrSuperuserOnly(permissions.BasePermission):
    '''Accept POST (create) requests, superusers-only otherwise.'''

    def has_object_permissions(self, request, view, obj):
        return request.method == 'POST' or request.user.is_superuser

## Instruction:
Make IsPostOrSuperuserOnly a non-object-level permission.
## Code After:

from rest_framework import permissions


class IsSuperuserOrReadOnly(permissions.BasePermission):
    '''Allow writes if superuser, read-only otherwise.'''

    def has_permission(self, request, view):
        return (request.user.is_superuser or
                request.method in permissions.SAFE_METHODS)


class IsUserOrSuperuser(permissions.BasePermission):
    '''Accept only the users themselves or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj


class IsAdvisorOrSuperuser(permissions.BasePermission):
    '''Accept only the school's advisor or superusers.'''

    def has_object_permission(self, request, view, obj):
        return request.user.is_superuser or request.user == obj.advisor


class IsPostOrSuperuserOnly(permissions.BasePermission):
    '''Accept POST (create) requests, superusers-only otherwise.'''

    def has_permission(self, request, view):
        return request.method == 'POST' or request.user.is_superuser
