diff --git a/cms/djangoapps/contentstore/views/__init__.py b/cms/djangoapps/contentstore/views/__init__.py
index 6211169bb2..7458a883c8 100644
--- a/cms/djangoapps/contentstore/views/__init__.py
+++ b/cms/djangoapps/contentstore/views/__init__.py
@@ -14,6 +14,7 @@ from .item import *
from .import_export import *
from .preview import *
from .public import *
+from .push_to_lms import *
from .user import *
from .tabs import *
from .transcripts_ajax import *
diff --git a/cms/djangoapps/contentstore/views/push_to_lms.py b/cms/djangoapps/contentstore/views/push_to_lms.py
new file mode 100644
index 0000000000..2a53cceddc
--- /dev/null
+++ b/cms/djangoapps/contentstore/views/push_to_lms.py
@@ -0,0 +1,39 @@
+import os
+import logging
+
+from django.conf import settings
+from django_future.csrf import ensure_csrf_cookie
+from django.contrib.auth.decorators import login_required
+
+from mitxmako.shortcuts import render_to_response
+from xmodule.modulestore.django import modulestore
+
+from .access import get_location_and_verify_access
+
+log = logging.getLogger(__name__)
+
+@ensure_csrf_cookie
+@login_required
+def push_to_lms(request, org, course, name):
+ """
+ This method serves up the 'Push to LMS' page
+ """
+ location = get_location_and_verify_access(request, org, course, name)
+
+ course_module = modulestore().get_item(location)
+
+ log.debug('push_to_lms course_module=%s' % course_module)
+
+ msg = ""
+
+ if 'action' in request.GET and course_module.lms.giturl:
+ # do the push, using script
+ doexport = getattr(settings, 'CMS_EXPORT_COURSE_SCRIPT', '')
+ if doexport and os.path.exists(doexport):
+ cmd = '{0} {1} {2} {3}'.format(doexport, course_module.id, request.user, course_module.lms.giturl)
+ msg = os.popen(cmd).read()
+
+ return render_to_response('push_to_lms.html', {
+ 'context_course': course_module,
+ 'msg': msg,
+ })
diff --git a/cms/templates/push_to_lms.html b/cms/templates/push_to_lms.html
new file mode 100644
index 0000000000..25c2c5d774
--- /dev/null
+++ b/cms/templates/push_to_lms.html
@@ -0,0 +1,56 @@
+<%! from django.utils.translation import ugettext as _ %>
+<%inherit file="base.html" />
+<%namespace name='static' file='static_content.html'/>
+
+<%! from django.core.urlresolvers import reverse %>
+<%block name="title">${_("Push Course to LMS")}%block>
+<%block name="bodyclass">is-signedin course tools export%block>
+
+<%block name="content">
+
+
+
+
+
+
+
+
+
+
${_("About Push to LMS")}
+
${_("Use this to export your course to its github site.")}
+
${_("This will then trigger an automatic update of the main LMS site")}
+ ${_("and update the contents of your course visible there to students.")}
+
+
+ - ${_("Your course:")} ${context_course.id}
+ - ${_("Course github site:")} ${context_course.lms.giturl}
+ % if msg:
+ - msg:
${msg|n}
+ % endif
+
+
+
+
+
+
+
+
+
+
+%block>
diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html
index ac9067e6be..201bd599a6 100644
--- a/cms/templates/widgets/header.html
+++ b/cms/templates/widgets/header.html
@@ -104,6 +104,11 @@
${_("Export")}
+ % if settings.MITX_FEATURES.get('ENABLE_PUSH_TO_LMS') and 'allow_push_to_lms' in context_course.advanced_modules:
+
+ ${_("Push to LMS")}
+
+ % endif
diff --git a/cms/urls.py b/cms/urls.py
index d21f0a2222..2360eadfb5 100644
--- a/cms/urls.py
+++ b/cms/urls.py
@@ -96,8 +96,16 @@ urlpatterns += patterns('',
url(r'^i18n.js$', 'django.views.i18n.javascript_catalog', js_info_dict),
)
-if settings.FEATURES.get('ENABLE_SERVICE_STATUS'):
- urlpatterns += patterns('',
+
+if settings.FEATURES.get('ENABLE_PUSH_TO_LMS'):
+ urlpatterns += (url(r'^(?P[^/]+)/(?P[^/]+)/push/(?P[^/]+)$',
+ 'contentstore.views.push_to_lms', name='push_to_lms'),)
+
+if settings.ENABLE_JASMINE:
+ urlpatterns += (url(r'^_jasmine/', include('django_jasmine.urls')),)
+
+if settings.MITX_FEATURES.get('ENABLE_SERVICE_STATUS'):
+ urlpatterns += (
url(r'^status/', include('service_status.urls')),
)
diff --git a/scripts/cms_export_to_github b/scripts/cms_export_to_github
new file mode 100755
index 0000000000..ac9eb97337
--- /dev/null
+++ b/scripts/cms_export_to_github
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+#
+# python script to export course from CMS to github
+#
+# Usage: python cms_export_to_github []
+#
+
+import os, sys, string, re
+import datetime
+
+DIR = "/mnt/data_export"
+
+#-----------------------------------------------------------------------------
+# usage
+
+def usage():
+ print "Usage: python cms_export_to_github []"
+
+#-----------------------------------------------------------------------------
+
+try:
+ course_loc = sys.argv.pop(1)
+ username = sys.argv.pop(1)
+ repo = sys.argv.pop(1)
+except:
+ usage()
+ sys.exit(0)
+
+if course_loc.startswith('i4x://'):
+ course_loc = course_loc[6:]
+
+m = re.match('git@[^ ]+\.git', repo)
+if not m:
+ print "Oops, not a git ssh url?"
+ print repo
+ print "Expecting something like git@github.com:mitocw/edx4edx_lite.git"
+ sys.exit(-1)
+
+if len(sys.argv)>1:
+ rdir = sys.argv.pop(1)
+ rdir = os.path.basename(rdir)
+else:
+ rdir = repo.rsplit('/',1)[-1].rsplit('.git',1)[0]
+print "rdir = %s" % rdir
+
+rdirp = '%s/%s' % (DIR, rdir)
+if os.path.exists(rdirp):
+ print "directory already exists, doing a git pull instead of git clone"
+ cmd = 'cd %s/%s; git pull' % (DIR, rdir)
+else:
+ cmd = 'cd %s; git clone "%s"' % (DIR, repo)
+
+print cmd
+ret_git = os.popen(cmd).read()
+print ret_git
+
+if not os.path.exists('%s/%s' % (DIR, rdir)):
+ print "git clone failed!"
+ sys.exit(-1)
+
+#-----------------------------------------------------------------------------
+# export course
+
+cmd = "./DJANGO-ADMIN-CMS export %s %s" % (course_loc, rdirp)
+print cmd
+ret_export = os.popen(cmd).read()
+print ret_export
+
+#-----------------------------------------------------------------------------
+# push to github
+
+dt = datetime.datetime.now()
+cmd = 'cd %s; git add .; git commit -a -m "(%s) Export %s"; git push' % (rdirp, username, dt)
+print cmd
+ret_push = os.popen(cmd).read()
+print ret_push
+
+
diff --git a/scripts/cms_export_to_github_local b/scripts/cms_export_to_github_local
new file mode 100755
index 0000000000..6cb066b0cb
--- /dev/null
+++ b/scripts/cms_export_to_github_local
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+cd ~/mitx_all
+source STARTUP
+cd edx-platform
+
+python scripts/cms_export_to_github $*