Commit 00889782 by Mat Peterson Committed by Ben McMorran

Set GlobalStaff permissions on reruns

parent e8763ef7
...@@ -240,6 +240,8 @@ def course_rerun_handler(request, course_key_string): ...@@ -240,6 +240,8 @@ def course_rerun_handler(request, course_key_string):
GET GET
html: return html page with form to rerun a course for the given course id 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_key = CourseKey.from_string(course_key_string)
course_module = _get_course_module(course_key, request.user, depth=3) course_module = _get_course_module(course_key, request.user, depth=3)
if request.method == 'GET': if request.method == 'GET':
...@@ -395,8 +397,9 @@ def course_listing(request): ...@@ -395,8 +397,9 @@ def course_listing(request):
'user': request.user, 'user': request.user,
'request_course_creator_url': reverse('contentstore.views.request_course_creator'), 'request_course_creator_url': reverse('contentstore.views.request_course_creator'),
'course_creator_status': _get_course_creator_status(request.user), '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_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)
}) })
......
...@@ -47,6 +47,10 @@ CELERY_ALWAYS_EAGER = True ...@@ -47,6 +47,10 @@ CELERY_ALWAYS_EAGER = True
# CELERY_ALWAYS_EAGER = False # CELERY_ALWAYS_EAGER = False
# BROKER_URL = 'redis://' # BROKER_URL = 'redis://'
################################ COURSE RERUNS ################################
FEATURES['ALLOW_COURSE_RERUNS'] = True
################################ DEBUG TOOLBAR ################################ ################################ DEBUG TOOLBAR ################################
INSTALLED_APPS += ('debug_toolbar', 'debug_toolbar_mongo') INSTALLED_APPS += ('debug_toolbar', 'debug_toolbar_mongo')
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
......
...@@ -77,6 +77,25 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"], ...@@ -77,6 +77,25 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"],
$('.new-course-save').off('click'); $('.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) { var addNewCourse = function (e) {
e.preventDefault(); e.preventDefault();
$('.new-course-button').addClass('is-disabled'); $('.new-course-button').addClass('is-disabled');
...@@ -89,25 +108,6 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"], ...@@ -89,25 +108,6 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"],
$cancelButton.bind('click', cancelNewCourse); $cancelButton.bind('click', cancelNewCourse);
CancelOnEscape($cancelButton); 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. // Ensure that org/course_num/run < 65 chars.
var validateTotalCourseItemsLength = function () { var validateTotalCourseItemsLength = function () {
var totalLength = _.reduce( var totalLength = _.reduce(
......
...@@ -129,7 +129,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio ...@@ -129,7 +129,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio
</li> </li>
</ol> </ol>
<input type="hidden" value="" class="allow-unicode-course-id" /> <!-- TODO: need to add support for allow_unicode_course_id in real view's template --> <input type="hidden" value="${allow_unicode_course_id}" class="allow-unicode-course-id" /> <!-- TODO: need to add support for allow_unicode_course_id in real view's template -->
</fieldset> </fieldset>
</div> </div>
......
...@@ -123,7 +123,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) { ...@@ -123,7 +123,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
</div> </div>
<div class="actions"> <div class="actions">
<input type="hidden" value="${ allow_unicode_course_id }" class="allow-unicode-course-id" /> <input type="hidden" value="${allow_unicode_course_id}" class="allow-unicode-course-id" />
<input type="submit" value="${_('Create')}" class="action action-primary new-course-save" /> <input type="submit" value="${_('Create')}" class="action action-primary new-course-save" />
<input type="button" value="${_('Cancel')}" class="action action-secondary action-cancel new-course-cancel" /> <input type="button" value="${_('Cancel')}" class="action action-secondary action-cancel new-course-cancel" />
</div> </div>
...@@ -132,7 +132,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) { ...@@ -132,7 +132,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
% endif % endif
<!-- STATE: processing courses --> <!-- STATE: processing courses -->
%if allow_course_reruns and len(unsucceeded_course_actions) > 0: %if allow_course_reruns and rerun_creator_status and len(unsucceeded_course_actions) > 0:
<div class="courses courses-processing"> <div class="courses courses-processing">
<h3 class="title">Courses Being Processed</h3> <h3 class="title">Courses Being Processed</h3>
...@@ -248,7 +248,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) { ...@@ -248,7 +248,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
</a> </a>
<ul class="item-actions course-actions"> <ul class="item-actions course-actions">
% if allow_course_reruns and course_creator_status=='granted': % if allow_course_reruns and rerun_creator_status and course_creator_status=='granted':
<li class="action action-rerun"> <li class="action action-rerun">
<a href="${rerun_link}" class="button rerun-button">${_("Re-run Course")}</a> <a href="${rerun_link}" class="button rerun-button">${_("Re-run Course")}</a>
</li> </li>
...@@ -259,7 +259,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) { ...@@ -259,7 +259,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
</ul> </ul>
</li> </li>
%endfor %endfor
% if course_creator_status=='granted': % if allow_course_reruns and rerun_creator_status and course_creator_status=='granted':
<script type="text/javascript"> <script type="text/javascript">
$('.course-item').addClass('can-rerun'); $('.course-item').addClass('can-rerun');
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment