From 7f32aae47d1510067c6cb8365f6667b3e8a60fb4 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 30 Jan 2013 11:50:11 -0500 Subject: [PATCH] rename method to something that actually better reflects what it is doing. Also rename a variable to help with readability --- cms/djangoapps/contentstore/tests/tests.py | 4 ++-- cms/djangoapps/contentstore/views.py | 10 +++++----- cms/static/coffee/src/views/tabs.coffee | 2 +- cms/urls.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index fd811fb101..8eddf000fe 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -362,11 +362,11 @@ class ContentStoreTest(TestCase): if tab['type'] == 'static_tab': reverse_tabs.insert(0, 'i4x://edX/full/static_tab/{0}'.format(tab['url_slug'])) - resp = self.client.post(reverse('reorder_tabs'), json.dumps({'tabs':reverse_tabs}), "application/json") + resp = self.client.post(reverse('reorder_static_tabs'), json.dumps({'tabs':reverse_tabs}), "application/json") course = ms.get_item(Location(['i4x','edX','full','course','6.002_Spring_2012', None])) + # compare to make sure that the tabs information is in the expected order after the server call - course_tabs = [] for tab in course.tabs: if tab['type'] == 'static_tab': diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index cf7c3984fb..b8981ecaa0 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -906,19 +906,19 @@ def edit_static(request, org, course, coursename): @login_required @expect_json -def reorder_tabs(request): +def reorder_static_tabs(request): tabs = request.POST['tabs'] course = get_course_for_item(tabs[0]) if not has_access(request.user, course.location): raise PermissionDenied() - # get list of course_tabs - course_tabs = [t for t in course.tabs if t['type'] == 'static_tab'] - + # get list of existing static tabs in course # make sure they are the same lengths (i.e. the number of passed in tabs equals the number # that we know about) otherwise we can drop some! - if len(course_tabs) != len(tabs): + + existing_static_tabs = [t for t in course.tabs if t['type'] == 'static_tab'] + if len(existing_static_tabs) != len(tabs): return HttpResponseBadRequest() # load all reference tabs, return BadRequest if we can't find any of them diff --git a/cms/static/coffee/src/views/tabs.coffee b/cms/static/coffee/src/views/tabs.coffee index 3799eb25ee..5a826c1794 100644 --- a/cms/static/coffee/src/views/tabs.coffee +++ b/cms/static/coffee/src/views/tabs.coffee @@ -31,7 +31,7 @@ class CMS.Views.TabsEdit extends Backbone.View ) $.ajax({ type:'POST', - url: '/reorder_tabs', + url: '/reorder_static_tabs', data: JSON.stringify({ tabs : tabs }), diff --git a/cms/urls.py b/cms/urls.py index 2b329dc16b..406d3966bb 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -17,7 +17,7 @@ urlpatterns = ('', url(r'^publish_draft$', 'contentstore.views.publish_draft', name='publish_draft'), url(r'^unpublish_unit$', 'contentstore.views.unpublish_unit', name='unpublish_unit'), url(r'^create_new_course', 'contentstore.views.create_new_course', name='create_new_course'), - url(r'^reorder_tabs', 'contentstore.views.reorder_tabs', name='reorder_tabs'), + url(r'^reorder_static_tabs', 'contentstore.views.reorder_static_tabs', name='reorder_static_tabs'), url(r'^(?P[^/]+)/(?P[^/]+)/course/(?P[^/]+)$', 'contentstore.views.course_index', name='course_index'),