Commit 4088ac54 by Calen Pennington

Isolate manual git reload behind a feature flag

parent 579544ec
......@@ -88,34 +88,35 @@ def instructor_dashboard(request, course_id):
# process actions from form POST
action = request.POST.get('action', '')
if 'GIT pull' in action:
data_dir = course.metadata['data_dir']
log.debug('git pull %s' % (data_dir))
gdir = settings.DATA_DIR / data_dir
if not os.path.exists(gdir):
msg += "====> ERROR in gitreload - no such directory %s" % gdir
else:
cmd = "cd %s; git reset --hard HEAD; git clean -f -d; git pull origin; chmod g+w course.xml" % gdir
msg += "git pull on %s:<p>" % data_dir
msg += "<pre>%s</pre></p>" % escape(os.popen(cmd).read())
track.views.server_track(request, 'git pull %s' % data_dir, {}, page='idashboard')
if 'Reload course' in action:
log.debug('reloading %s (%s)' % (course_id, course))
try:
if settings.MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD']:
if 'GIT pull' in action:
data_dir = course.metadata['data_dir']
modulestore().try_load_course(data_dir)
msg += "<br/><p>Course reloaded from %s</p>" % data_dir
track.views.server_track(request, 'reload %s' % data_dir, {}, page='idashboard')
course_errors = modulestore().get_item_errors(course.location)
msg += '<ul>'
for cmsg, cerr in course_errors:
msg += "<li>%s: <pre>%s</pre>" % (cmsg,escape(cerr))
msg += '</ul>'
except Exception as err:
msg += '<br/><p>Error: %s</p>' % escape(err)
elif action == 'Dump list of enrolled students':
log.debug('git pull %s' % (data_dir))
gdir = settings.DATA_DIR / data_dir
if not os.path.exists(gdir):
msg += "====> ERROR in gitreload - no such directory %s" % gdir
else:
cmd = "cd %s; git reset --hard HEAD; git clean -f -d; git pull origin; chmod g+w course.xml" % gdir
msg += "git pull on %s:<p>" % data_dir
msg += "<pre>%s</pre></p>" % escape(os.popen(cmd).read())
track.views.server_track(request, 'git pull %s' % data_dir, {}, page='idashboard')
if 'Reload course' in action:
log.debug('reloading %s (%s)' % (course_id, course))
try:
data_dir = course.metadata['data_dir']
modulestore().try_load_course(data_dir)
msg += "<br/><p>Course reloaded from %s</p>" % data_dir
track.views.server_track(request, 'reload %s' % data_dir, {}, page='idashboard')
course_errors = modulestore().get_item_errors(course.location)
msg += '<ul>'
for cmsg, cerr in course_errors:
msg += "<li>%s: <pre>%s</pre>" % (cmsg,escape(cerr))
msg += '</ul>'
except Exception as err:
msg += '<br/><p>Error: %s</p>' % escape(err)
if action == 'Dump list of enrolled students':
log.debug(action)
datatable = get_student_grade_summary_data(request, course, course_id, get_grades=False)
datatable['title'] = 'List of students enrolled in %s' % course_id
......
......@@ -73,6 +73,7 @@ MITX_FEATURES = {
'ENABLE_SQL_TRACKING_LOGS': False,
'ENABLE_LMS_MIGRATION': False,
'ENABLE_MANUAL_GIT_RELOAD': False,
'DISABLE_LOGIN_BUTTON': False, # used in systems where login is automatic, eg MIT SSL
......
......@@ -18,6 +18,7 @@ MITX_FEATURES['ENABLE_SQL_TRACKING_LOGS'] = True
MITX_FEATURES['SUBDOMAIN_COURSE_LISTINGS'] = False # Enable to test subdomains--otherwise, want all courses to show up
MITX_FEATURES['SUBDOMAIN_BRANDING'] = True
MITX_FEATURES['FORCE_UNIVERSITY_DOMAIN'] = None # show all university courses if in dev (ie don't use HTTP_HOST)
MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD'] = True
WIKI_ENABLED = True
......
......@@ -71,7 +71,7 @@ table.stat_table td {
<hr width="40%" style="align:left">
%endif
%if admin_access:
%if settings.MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD'] and admin_access:
<p>
<input type="submit" name="action" value="Reload course from XML files">
<input type="submit" name="action" value="GIT pull and Reload course">
......
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