Set GlobalStaff permissions on reruns
This commit is contained in:
committed by
Ben McMorran
parent
e8763ef715
commit
0088978281
@@ -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)
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -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',)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -129,7 +129,7 @@ require(["domReady!", "jquery", "jquery.form", "js/views/course_rerun"], functio
|
||||
</li>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
</div>
|
||||
|
||||
<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="button" value="${_('Cancel')}" class="action action-secondary action-cancel new-course-cancel" />
|
||||
</div>
|
||||
@@ -132,7 +132,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
% endif
|
||||
|
||||
<!-- 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">
|
||||
<h3 class="title">Courses Being Processed</h3>
|
||||
|
||||
@@ -248,7 +248,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
</a>
|
||||
|
||||
<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">
|
||||
<a href="${rerun_link}" class="button rerun-button">${_("Re-run Course")}</a>
|
||||
</li>
|
||||
@@ -259,7 +259,7 @@ require(["domReady!", "jquery", "jquery.form", "js/index"], function(doc, $) {
|
||||
</ul>
|
||||
</li>
|
||||
%endfor
|
||||
% if course_creator_status=='granted':
|
||||
% if allow_course_reruns and rerun_creator_status and course_creator_status=='granted':
|
||||
<script type="text/javascript">
|
||||
$('.course-item').addClass('can-rerun');
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user