Commit 91dcef7f by ichuang

add gitreload to instructor dashboard

parent 4341ea76
# ======== Instructor views ============================================================================= # ======== Instructor views =============================================================================
import csv import csv
import itertools
import json import json
import logging import logging
import os
import urllib import urllib
import itertools
from functools import partial from functools import partial
from collections import defaultdict from collections import defaultdict
...@@ -85,7 +86,18 @@ def instructor_dashboard(request, course_id): ...@@ -85,7 +86,18 @@ def instructor_dashboard(request, course_id):
# process actions from form POST # process actions from form POST
action = request.POST.get('action', '') action = request.POST.get('action', '')
if 'Reload' in 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())
if 'Reload course' in action:
log.debug('reloading %s (%s)' % (course_id, course)) log.debug('reloading %s (%s)' % (course_id, course))
try: try:
data_dir = course.metadata['data_dir'] data_dir = course.metadata['data_dir']
......
...@@ -70,7 +70,8 @@ table.stat_table td { ...@@ -70,7 +70,8 @@ table.stat_table td {
%if admin_access: %if admin_access:
<p> <p>
<input type="submit" name="action" value="Reload course from XML files"> <input type="submit" name="action" value="Reload course from XML files">
<input type="submit" name="action" value="GIT pull and Reload course">
%endif %endif
</form> </form>
......
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