def get_courses_accessible_to_user(request):
 if GlobalStaff().has_user(request.user):
  (courses, in_process_course_actions) = _accessible_courses_summary_list(request)
 else:
  try:
   (courses, in_process_course_actions) = _accessible_courses_list_from_groups(request)
  except AccessListFallback:
   (courses, in_process_course_actions) = _accessible_courses_summary_list(request)
 return (courses, in_process_course_actions)

def get_courses_accessible_to_user ( request ) : if GlobalStaff ( ) . has_user ( request . user ) : ( courses , in_process_course_actions ) = _accessible_courses_summary_list ( request ) else : try : ( courses , in_process_course_actions ) = _accessible_courses_list_from_groups ( request ) except AccessListFallback : ( courses , in_process_course_actions ) = _accessible_courses_summary_list ( request ) return ( courses , in_process_course_actions )
try to get all courses by first reversing django groups and fallback to old method if it fails note: overhead of pymongo reads will increase if getting courses from django groups fails .