Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
b0ff3053
Commit
b0ff3053
authored
Jul 03, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add development code for pushing CMS changes to github
parent
cf269130
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
5 deletions
+59
-5
cms/djangoapps/contentstore/views.py
+10
-1
cms/djangoapps/github_sync/__init__.py
+17
-2
cms/envs/common.py
+1
-0
cms/envs/dev.py
+31
-2
No files found.
cms/djangoapps/contentstore/views.py
View file @
b0ff3053
...
...
@@ -4,6 +4,8 @@ from django.http import HttpResponse
from
django_future.csrf
import
ensure_csrf_cookie
from
fs.osfs
import
OSFS
from
django.core.urlresolvers
import
reverse
from
xmodule.modulestore
import
Location
from
github_sync
import
repo_path_from_location
,
export_to_github
from
mitxmako.shortcuts
import
render_to_response
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -12,7 +14,6 @@ from xmodule.modulestore.django import modulestore
@ensure_csrf_cookie
def
index
(
request
):
courses
=
modulestore
()
.
get_items
([
'i4x'
,
None
,
None
,
'course'
,
None
])
print
courses
return
render_to_response
(
'index.html'
,
{
'courses'
:
[(
course
.
metadata
[
'display_name'
],
reverse
(
'course_index'
,
args
=
[
...
...
@@ -46,6 +47,14 @@ def save_item(request):
item_id
=
request
.
POST
[
'id'
]
data
=
json
.
loads
(
request
.
POST
[
'data'
])
modulestore
()
.
update_item
(
item_id
,
data
)
# Export the course back to github
course_location
=
Location
(
item_id
)
.
_replace
(
category
=
'course'
,
name
=
None
)
courses
=
modulestore
()
.
get_items
(
course_location
)
for
course
in
courses
:
repo_path
=
repo_path_from_location
(
course
.
location
)
export_to_github
(
course
,
repo_path
,
"CMS Edit"
)
return
HttpResponse
(
json
.
dumps
({}))
...
...
cms/djangoapps/github_sync/__init__.py
View file @
b0ff3053
from
git
import
Repo
from
contentstore
import
import_from_xml
from
fs.osfs
import
OSFS
import
os
from
xmodule.modulestore
import
Location
from
django.conf
import
settings
def
import_from_github
(
repo_settings
):
...
...
@@ -13,17 +16,28 @@ def import_from_github(repo_settings):
org: name of the
"""
repo_path
=
repo_settings
[
'path'
]
if
not
os
.
path
.
isdir
(
repo_path
):
Repo
.
clone_from
(
repo_settings
[
'origin'
],
repo_path
)
git_repo
=
Repo
(
repo_path
)
origin
=
git_repo
.
remotes
.
origin
origin
.
fetch
()
# Do a hard reset to the remote branch so that we have a clean import
git_repo
.
heads
[
repo_settings
[
'branch'
]]
.
checkout
(
)
git_repo
.
git
.
checkout
(
repo_settings
[
'branch'
]
)
git_repo
.
head
.
reset
(
'origin/
%
s'
%
repo_settings
[
'branch'
],
index
=
True
,
working_tree
=
True
)
return
git_repo
.
head
.
commit
.
hexsha
,
import_from_xml
(
repo_settings
[
'org'
],
repo_settings
[
'course'
],
repo_path
)
def
repo_path_from_location
(
location
):
location
=
Location
(
location
)
for
name
,
repo
in
settings
.
REPOS
.
items
():
if
repo
[
'org'
]
==
location
.
org
and
repo
[
'course'
]
==
location
.
course
:
return
repo
[
'path'
]
def
export_to_github
(
course
,
repo_path
,
commit_message
):
fs
=
OSFS
(
repo_path
)
xml
=
course
.
export_to_xml
(
fs
)
...
...
@@ -37,4 +51,5 @@ def export_to_github(course, repo_path, commit_message):
git_repo
.
git
.
commit
(
m
=
commit_message
)
origin
=
git_repo
.
remotes
.
origin
origin
.
push
()
if
settings
.
MITX_FEATURES
[
'GITHUB_PUSH'
]:
origin
.
push
()
cms/envs/common.py
View file @
b0ff3053
...
...
@@ -30,6 +30,7 @@ from path import path
MITX_FEATURES
=
{
'USE_DJANGO_PIPELINE'
:
True
,
'GITHUB_PUSH'
:
False
,
}
############################# SET PATH INFORMATION #############################
...
...
cms/envs/dev.py
View file @
b0ff3053
...
...
@@ -36,8 +36,37 @@ REPOS = {
'path'
:
REPO_ROOT
/
"edx4edx"
,
'org'
:
'edx'
,
'course'
:
'edx4edx'
,
'branch'
:
'for_cms'
}
'branch'
:
'for_cms'
,
'origin'
:
'git@github.com:MITx/edx4edx.git'
,
},
'6002x-fall-2012'
:
{
'path'
:
REPO_ROOT
/
'6002x-fall-2012'
,
'org'
:
'mit.edu'
,
'course'
:
'6.002x'
,
'branch'
:
'master'
,
'origin'
:
'git@github.com:MITx/6002x-fall-2012.git'
,
},
'6.00x'
:
{
'path'
:
REPO_ROOT
/
'6.00x'
,
'org'
:
'mit.edu'
,
'course'
:
'6.00x'
,
'branch'
:
'master'
,
'origin'
:
'git@github.com:MITx/6.00x.git'
,
},
'7.00x'
:
{
'path'
:
REPO_ROOT
/
'7.00x'
,
'org'
:
'mit.edu'
,
'course'
:
'7.00x'
,
'branch'
:
'master'
,
'origin'
:
'git@github.com:MITx/7.00x.git'
,
},
'3.091x'
:
{
'path'
:
REPO_ROOT
/
'3.091x'
,
'org'
:
'mit.edu'
,
'course'
:
'3.091x'
,
'branch'
:
'master'
,
'origin'
:
'git@github.com:MITx/3.091x.git'
,
},
}
CACHES
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment