Commit d7d2d537 by Calen Pennington

Merge pull request #742 from MITx/feature/cale/cms-to-lms-links

Add links from the editing page for the cms to the corresponding page in...
parents e2660cf7 f3772d15
...@@ -8,6 +8,7 @@ from django.contrib.auth.decorators import login_required ...@@ -8,6 +8,7 @@ from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf from django.core.context_processors import csrf
from django_future.csrf import ensure_csrf_cookie from django_future.csrf import ensure_csrf_cookie
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.x_module import ModuleSystem from xmodule.x_module import ModuleSystem
...@@ -105,13 +106,25 @@ def edit_item(request): ...@@ -105,13 +106,25 @@ def edit_item(request):
item = modulestore().get_item(item_location) item = modulestore().get_item(item_location)
item.get_html = wrap_xmodule(item.get_html, item, "xmodule_edit.html") item.get_html = wrap_xmodule(item.get_html, item, "xmodule_edit.html")
if settings.LMS_BASE is not None:
lms_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format(
lms_base=settings.LMS_BASE,
# TODO: These will need to be changed to point to the particular instance of this problem in the particular course
course_id=modulestore().get_containing_courses()[0].id,
location=item.location,
)
else:
lms_link = None
return render_to_response('unit.html', { return render_to_response('unit.html', {
'contents': item.get_html(), 'contents': item.get_html(),
'js_module': item.js_module_name, 'js_module': item.js_module_name,
'category': item.category, 'category': item.category,
'url_name': item.url_name, 'url_name': item.url_name,
'previews': get_module_previews(request, item), 'previews': get_module_previews(request, item),
'metadata': item.metadata 'metadata': item.metadata,
# TODO: It would be nice to able to use reverse here in some form, but we don't have the lms urls imported
'lms_link': lms_link,
}) })
......
...@@ -19,6 +19,8 @@ DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' ...@@ -19,6 +19,8 @@ DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
with open(ENV_ROOT / "cms.env.json") as env_file: with open(ENV_ROOT / "cms.env.json") as env_file:
ENV_TOKENS = json.load(env_file) ENV_TOKENS = json.load(env_file)
LMS_BASE = ENV_TOKENS.get('LMS_BASE')
SITE_NAME = ENV_TOKENS['SITE_NAME'] SITE_NAME = ENV_TOKENS['SITE_NAME']
LOG_DIR = ENV_TOKENS['LOG_DIR'] LOG_DIR = ENV_TOKENS['LOG_DIR']
......
...@@ -88,6 +88,8 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -88,6 +88,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.csrf', # necessary for csrf protection 'django.core.context_processors.csrf', # necessary for csrf protection
) )
LMS_BASE = None
################################# Jasmine ################################### ################################# Jasmine ###################################
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee' JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
......
...@@ -36,6 +36,8 @@ DATABASES = { ...@@ -36,6 +36,8 @@ DATABASES = {
} }
} }
LMS_BASE = "http://localhost:8000"
REPOS = { REPOS = {
'edx4edx': { 'edx4edx': {
'branch': 'master', 'branch': 'master',
......
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
</section> </section>
</section> </section>
${contents} ${contents}
% if lms_link is not None:
<a class="lms-link" href="${lms_link}">View in LMS</a>
% endif
<section class="previews"> <section class="previews">
% for preview in previews: % for preview in previews:
<section class="preview"> <section class="preview">
......
...@@ -338,7 +338,6 @@ class ModuleStore(object): ...@@ -338,7 +338,6 @@ class ModuleStore(object):
''' '''
raise NotImplementedError raise NotImplementedError
def get_parent_locations(self, location): def get_parent_locations(self, location):
'''Find all locations that are the parents of this location. Needed '''Find all locations that are the parents of this location. Needed
for path_to_location(). for path_to_location().
...@@ -347,6 +346,22 @@ class ModuleStore(object): ...@@ -347,6 +346,22 @@ class ModuleStore(object):
''' '''
raise NotImplementedError raise NotImplementedError
def get_containing_courses(self, location):
'''
Returns the list of courses that contains the specified location
TODO (cpennington): This should really take a module instance id,
rather than a location
'''
courses = [
course
for course in self.get_courses()
if course.location.org == location.org
and course.location.course == location.course
]
return courses
class ModuleStoreBase(ModuleStore): class ModuleStoreBase(ModuleStore):
''' '''
......
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