From 0088978281fc1f29400bd166388782f8b2e9d097 Mon Sep 17 00:00:00 2001 From: Mat Peterson Date: Thu, 14 Aug 2014 14:47:52 +0000 Subject: [PATCH] Set GlobalStaff permissions on reruns --- cms/djangoapps/contentstore/views/course.py | 5 ++- cms/envs/devstack.py | 4 +++ cms/static/js/index.js | 38 ++++++++++----------- cms/templates/course-create-rerun.html | 2 +- cms/templates/index.html | 8 ++--- 5 files changed, 32 insertions(+), 25 deletions(-) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 2bf9efa36a..0443f92827 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -240,6 +240,8 @@ def course_rerun_handler(request, course_key_string): GET html: return html page with form to rerun a course for the given course id """ + if not GlobalStaff().has_user(request.user): + raise PermissionDenied() course_key = CourseKey.from_string(course_key_string) course_module = _get_course_module(course_key, request.user, depth=3) if request.method == 'GET': @@ -395,8 +397,9 @@ def course_listing(request): 'user': request.user, 'request_course_creator_url': reverse('contentstore.views.request_course_creator'), 'course_creator_status': _get_course_creator_status(request.user), + 'rerun_creator_status': GlobalStaff().has_user(request.user), 'allow_unicode_course_id': settings.FEATURES.get('ALLOW_UNICODE_COURSE_ID', False), - 'allow_course_reruns': settings.FEATURES.get('ALLOW_COURSE_RERUNS', True) + 'allow_course_reruns': settings.FEATURES.get('ALLOW_COURSE_RERUNS', False) }) diff --git a/cms/envs/devstack.py b/cms/envs/devstack.py index cc41414c72..67bf940d40 100644 --- a/cms/envs/devstack.py +++ b/cms/envs/devstack.py @@ -47,6 +47,10 @@ CELERY_ALWAYS_EAGER = True # CELERY_ALWAYS_EAGER = False # BROKER_URL = 'redis://' +################################ COURSE RERUNS ################################ + +FEATURES['ALLOW_COURSE_RERUNS'] = True + ################################ DEBUG TOOLBAR ################################ INSTALLED_APPS += ('debug_toolbar', 'debug_toolbar_mongo') MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) diff --git a/cms/static/js/index.js b/cms/static/js/index.js index 51fe74ab60..bf7feb89b3 100644 --- a/cms/static/js/index.js +++ b/cms/static/js/index.js @@ -77,6 +77,25 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"], $('.new-course-save').off('click'); }; + // Check that a course (org, number, run) doesn't use any special characters + var validateCourseItemEncoding = function (item) { + var required = validateRequiredField(item); + if (required) { + return required; + } + if ($('.allow-unicode-course-id').val() === 'True'){ + if (/\s/g.test(item)) { + return gettext('Please do not use any spaces in this field.'); + } + } + else{ + if (item !== encodeURIComponent(item)) { + return gettext('Please do not use any spaces or special characters in this field.'); + } + } + return ''; + }; + var addNewCourse = function (e) { e.preventDefault(); $('.new-course-button').addClass('is-disabled'); @@ -89,25 +108,6 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"], $cancelButton.bind('click', cancelNewCourse); CancelOnEscape($cancelButton); - // Check that a course (org, number, run) doesn't use any special characters - var validateCourseItemEncoding = function (item) { - var required = validateRequiredField(item); - if (required) { - return required; - } - if ($('.allow-unicode-course-id').val() === 'True'){ - if (/\s/g.test(item)) { - return gettext('Please do not use any spaces in this field.'); - } - } - else{ - if (item !== encodeURIComponent(item)) { - return gettext('Please do not use any spaces or special characters in this field.'); - } - } - return ''; - }; - // Ensure that org/course_num/run < 65 chars. var validateTotalCourseItemsLength = function () { var totalLength = _.reduce( diff --git a/cms/templates/course-create-rerun.html b/cms/templates/course-create-rerun.html index 87f18d3431..2994fcf4e9 100644 --- a/cms/templates/course-create-rerun.html +++ b/cms/templates/course-create-rerun.html @@ -129,7 +129,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio - + diff --git a/cms/templates/index.html b/cms/templates/index.html index bda00eb77e..b89d8c75fe 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -123,7 +123,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
- +
@@ -132,7 +132,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) { % endif - %if allow_course_reruns and len(unsucceeded_course_actions) > 0: + %if allow_course_reruns and rerun_creator_status and len(unsucceeded_course_actions) > 0:

Courses Being Processed

@@ -248,7 +248,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) { %endfor - % if course_creator_status=='granted': + % if allow_course_reruns and rerun_creator_status and course_creator_status=='granted':