def require_level(level):
 if (level not in ['instructor', 'staff']):
  raise ValueError("unrecognized level '{}'".format(level))
 def decorator(func):
  def wrapped(*args, **kwargs):
   request = args[0]
   course = get_course_by_id(CourseKey.from_string(kwargs['course_id']))
   if has_access(request.user, level, course):
    return func(*args, **kwargs)
   else:
    return HttpResponseForbidden()
  return wrapped
 return decorator

def require_level ( level ) : if ( level not in [ 'instructor' , 'staff' ] ) : raise ValueError ( "unrecognized level '{}'" . format ( level ) ) def decorator ( func ) : def wrapped ( * args , ** kwargs ) : request = args [ 0 ] course = get_course_by_id ( CourseKey . from_string ( kwargs [ 'course_id' ] ) ) if has_access ( request . user , level , course ) : return func ( * args , ** kwargs ) else : return HttpResponseForbidden ( ) return wrapped return decorator
decorator with argument that requires an access level of the requesting user .