def reorder_tabs_handler(course_item, request):
 requested_tab_id_locators = request.json['tabs']
 old_tab_list = course_item.tabs
 new_tab_list = []
 for tab_id_locator in requested_tab_id_locators:
  tab = get_tab_by_tab_id_locator(old_tab_list, tab_id_locator)
  if (tab is None):
   return JsonResponse({'error': "Tab with id_locator '{0}' does not exist.".format(tab_id_locator)}, status=400)
  new_tab_list.append(tab)
 non_displayed_tabs = (set(old_tab_list) - set(new_tab_list))
 new_tab_list.extend(non_displayed_tabs)
 try:
  CourseTabList.validate_tabs(new_tab_list)
 except InvalidTabsException as exception:
  return JsonResponse({'error': 'New list of tabs is not valid: {0}.'.format(str(exception))}, status=400)
 course_item.tabs = new_tab_list
 modulestore().update_item(course_item, request.user.id)
 return JsonResponse()

def reorder_tabs_handler ( course_item , request ) : requested_tab_id_locators = request . json [ 'tabs' ] old_tab_list = course_item . tabs new_tab_list = [ ] for tab_id_locator in requested_tab_id_locators : tab = get_tab_by_tab_id_locator ( old_tab_list , tab_id_locator ) if ( tab is None ) : return JsonResponse ( { 'error' : "Tab with id_locator '{0}' does not exist." . format ( tab_id_locator ) } , status = 400 ) new_tab_list . append ( tab ) non_displayed_tabs = ( set ( old_tab_list ) - set ( new_tab_list ) ) new_tab_list . extend ( non_displayed_tabs ) try : CourseTabList . validate_tabs ( new_tab_list ) except InvalidTabsException as exception : return JsonResponse ( { 'error' : 'New list of tabs is not valid: {0}.' . format ( str ( exception ) ) } , status = 400 ) course_item . tabs = new_tab_list modulestore ( ) . update_item ( course_item , request . user . id ) return JsonResponse ( )
helper function for handling reorder of tabs request .