def has_staff_access_to_preview_mode(user, obj, course_key=None):
 if (course_key is None):
  if (isinstance(obj, CourseDescriptor) or isinstance(obj, CourseOverview)):
   course_key = obj.id
  elif isinstance(obj, ErrorDescriptor):
   course_key = obj.location.course_key
  elif isinstance(obj, XModule):
   course_key = obj.descriptor.course_key
  elif isinstance(obj, XBlock):
   course_key = obj.location.course_key
  elif isinstance(obj, CCXLocator):
   course_key = obj.to_course_locator()
  elif isinstance(obj, CourseKey):
   course_key = obj
  elif isinstance(obj, UsageKey):
   course_key = obj.course_key
 if (course_key is None):
  if GlobalStaff().has_user(user):
   return ACCESS_GRANTED
  else:
   return ACCESS_DENIED
 return _has_access_to_course(user, 'staff', course_key=course_key)

def has_staff_access_to_preview_mode ( user , obj , course_key = None ) : if ( course_key is None ) : if ( isinstance ( obj , CourseDescriptor ) or isinstance ( obj , CourseOverview ) ) : course_key = obj . id elif isinstance ( obj , ErrorDescriptor ) : course_key = obj . location . course_key elif isinstance ( obj , XModule ) : course_key = obj . descriptor . course_key elif isinstance ( obj , XBlock ) : course_key = obj . location . course_key elif isinstance ( obj , CCXLocator ) : course_key = obj . to_course_locator ( ) elif isinstance ( obj , CourseKey ) : course_key = obj elif isinstance ( obj , UsageKey ) : course_key = obj . course_key if ( course_key is None ) : if GlobalStaff ( ) . has_user ( user ) : return ACCESS_GRANTED else : return ACCESS_DENIED return _has_access_to_course ( user , 'staff' , course_key = course_key )
returns whether user has staff access to specified modules or not .