Internal/External Studio file URLs

- Changed link URL of file name to use public/LMS url
- Added toggle link to display all public URLs for instructor convenience
This commit is contained in:
Giulio Gratta
2014-02-12 11:05:14 -08:00
parent 2aac72934b
commit 3ffb6715e5
7 changed files with 20 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_http_methods
from django_future.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_POST
from django.conf import settings
from edxmako.shortcuts import render_to_response
from cache_toolbox.core import del_cached_content
@@ -290,10 +291,12 @@ def _get_asset_json(display_name, date, location, thumbnail_location, locked):
Helper method for formatting the asset information to send to client.
"""
asset_url = StaticContent.get_url_path_from_location(location)
external_url = settings.LMS_BASE + asset_url
return {
'display_name': display_name,
'date_added': get_default_time_display(date),
'url': asset_url,
'external_url': external_url,
'portable_url': StaticContent.get_static_path_from_location(location),
'thumbnail': StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_location is not None else None,
'locked': locked,

View File

@@ -36,15 +36,21 @@ class AssetsTestCase(CourseTestCase):
class BasicAssetsTestCase(AssetsTestCase):
location = Location(['i4x', 'foo', 'bar', 'asset', 'my_file_name.jpg'])
TEST_LMS_BASE = 'localhost:8000'
def test_basic(self):
resp = self.client.get(self.url, HTTP_ACCEPT='text/html')
self.assertEquals(resp.status_code, 200)
def test_static_url_generation(self):
location = Location(['i4x', 'foo', 'bar', 'asset', 'my_file_name.jpg'])
path = StaticContent.get_static_path_from_location(location)
path = StaticContent.get_static_path_from_location(self.location)
self.assertEquals(path, '/static/my_file_name.jpg')
def test_lms_url_generation(self):
url = self.TEST_LMS_BASE + StaticContent.get_url_path_from_location(self.location)
self.assertEquals(url, 'localhost:8000/i4x/foo/bar/asset/my_file_name.jpg')
def test_pdf_asset(self):
module_store = modulestore('direct')
_, course_items = import_from_xml(