From 91dcef7fd0fac0f5afcf50418158e4812dee7667 Mon Sep 17 00:00:00 2001
From: ichuang
Date: Sun, 2 Sep 2012 22:41:27 -0400
Subject: [PATCH] add gitreload to instructor dashboard
---
lms/djangoapps/instructor/views.py | 16 ++++++++++++++--
.../courseware/instructor_dashboard.html | 3 ++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py
index bfbfab6e25..5a3611285c 100644
--- a/lms/djangoapps/instructor/views.py
+++ b/lms/djangoapps/instructor/views.py
@@ -1,10 +1,11 @@
# ======== Instructor views =============================================================================
import csv
+import itertools
import json
import logging
+import os
import urllib
-import itertools
from functools import partial
from collections import defaultdict
@@ -85,7 +86,18 @@ def instructor_dashboard(request, course_id):
# process actions from form POST
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:" % data_dir
+ msg += "
%s
" % escape(os.popen(cmd).read())
+
+ if 'Reload course' in action:
log.debug('reloading %s (%s)' % (course_id, course))
try:
data_dir = course.metadata['data_dir']
diff --git a/lms/templates/courseware/instructor_dashboard.html b/lms/templates/courseware/instructor_dashboard.html
index 49b16cf122..29397e5c41 100644
--- a/lms/templates/courseware/instructor_dashboard.html
+++ b/lms/templates/courseware/instructor_dashboard.html
@@ -70,7 +70,8 @@ table.stat_table td {
%if admin_access:
-
+
+
%endif