From 3ffb6715e542c8467eaa04aed7c18f7f46a73676 Mon Sep 17 00:00:00 2001 From: Giulio Gratta Date: Wed, 12 Feb 2014 11:05:14 -0800 Subject: [PATCH 1/4] 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 --- cms/djangoapps/contentstore/views/assets.py | 3 +++ cms/djangoapps/contentstore/views/tests/test_assets.py | 10 ++++++++-- cms/static/js/models/asset.js | 1 + cms/static/js/views/asset.js | 1 + cms/static/sass/views/_assets.scss | 2 +- cms/templates/js/asset-library.underscore | 3 ++- cms/templates/js/asset.underscore | 5 ++++- 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cms/djangoapps/contentstore/views/assets.py b/cms/djangoapps/contentstore/views/assets.py index dd96cd213a..a1a8d93468 100644 --- a/cms/djangoapps/contentstore/views/assets.py +++ b/cms/djangoapps/contentstore/views/assets.py @@ -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, diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index b4af6f9fb4..6384269715 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -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( diff --git a/cms/static/js/models/asset.js b/cms/static/js/models/asset.js index 91055fb09b..bcf2589a4d 100644 --- a/cms/static/js/models/asset.js +++ b/cms/static/js/models/asset.js @@ -8,6 +8,7 @@ define(["backbone"], function(Backbone) { thumbnail: "", date_added: "", url: "", + external_url: "", portable_url: "", locked: false } diff --git a/cms/static/js/views/asset.js b/cms/static/js/views/asset.js index b6fd8fc8a6..df577816d7 100644 --- a/cms/static/js/views/asset.js +++ b/cms/static/js/views/asset.js @@ -18,6 +18,7 @@ var AssetView = BaseView.extend({ thumbnail: this.model.get('thumbnail'), date_added: this.model.get('date_added'), url: this.model.get('url'), + external_url: this.model.get('external_url'), portable_url: this.model.get('portable_url'), uniqueId: uniqueId })); diff --git a/cms/static/sass/views/_assets.scss b/cms/static/sass/views/_assets.scss index 830254d02c..8b59634a33 100644 --- a/cms/static/sass/views/_assets.scss +++ b/cms/static/sass/views/_assets.scss @@ -304,7 +304,7 @@ @include transition(all $tmg-f2 ease-in-out 0s); @extend %t-copy-sub2; box-shadow: none; - border: none; + border: 1px solid transparent; background: none; width: 100%; color: $gray-l2; diff --git a/cms/templates/js/asset-library.underscore b/cms/templates/js/asset-library.underscore index ad0a9f2f8e..9867f34cd4 100644 --- a/cms/templates/js/asset-library.underscore +++ b/cms/templates/js/asset-library.underscore @@ -16,7 +16,8 @@ <%= gettext("Preview") %> <%= gettext("Name") %> <%= gettext("Date Added") %> - <%= gettext("URL") %> + <%= gettext("Embed URL") %> + <%= gettext("External URL") %> <%= gettext("Actions") %> diff --git a/cms/templates/js/asset.underscore b/cms/templates/js/asset.underscore index 938ec10471..e38794af77 100644 --- a/cms/templates/js/asset.underscore +++ b/cms/templates/js/asset.underscore @@ -16,6 +16,9 @@ + + + - + \ No newline at end of file From 46bda852d683a4a354c13cde8b76b08953ade866 Mon Sep 17 00:00:00 2001 From: Mark Hoeber Date: Tue, 25 Feb 2014 14:26:50 -0500 Subject: [PATCH 2/4] Assets Page Template Update For embed vs. external URLs STUD-1338 --- cms/templates/asset_index.html | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cms/templates/asset_index.html b/cms/templates/asset_index.html index 8b96881f70..336cc5a1dc 100644 --- a/cms/templates/asset_index.html +++ b/cms/templates/asset_index.html @@ -156,11 +156,20 @@ require(["domReady", "jquery", "js/models/asset", "js/collections/asset",

${_("In addition to the files you upload on this page, any files that you add to the course appear in this list. These files include your course image, textbook chapters, and files that appear on your Course Handouts sidebar.")}

+

${_("File URLs")}

+
    +
  • ${_("You use the Embed URL value to link to the file or image from a component, a course update, or a course handout.")}
  • +
  • ${_("You use the External URL value to reference the file or image from outside of your course. Do not use the External URL as a link value within your course.")}
  • +
  • ${_("You can upload new files or view, download, or delete existing files. You can lock a file so that people who are not enrolled in your course cannot access that file.")}
  • + +
+
+

${_("What can I do on this page?")}

    -
  • ${_("You can upload new files or view, download, or delete existing files. You can lock a file so that people who are not enrolled in your course cannot access that file.")}
  • -
  • ${_("Use the URL listed for a file to create a link to that file in the Course Handouts sidebar or in the body of the course.")}
  • -
+
  • ${_("You can upload new files or view, download, or delete existing files. You can lock a file so that people who are not enrolled in your course cannot access that file.")}
  • + +
    From 3553fa7c50e1e3f470208327e2d2fe19098e274d Mon Sep 17 00:00:00 2001 From: Mark Hoeber Date: Tue, 25 Feb 2014 14:42:21 -0500 Subject: [PATCH 3/4] removed dup'd paragraph --- cms/templates/asset_index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/cms/templates/asset_index.html b/cms/templates/asset_index.html index 336cc5a1dc..96bbd31632 100644 --- a/cms/templates/asset_index.html +++ b/cms/templates/asset_index.html @@ -160,7 +160,6 @@ require(["domReady", "jquery", "js/models/asset", "js/collections/asset",
    • ${_("You use the Embed URL value to link to the file or image from a component, a course update, or a course handout.")}
    • ${_("You use the External URL value to reference the file or image from outside of your course. Do not use the External URL as a link value within your course.")}
    • -
    • ${_("You can upload new files or view, download, or delete existing files. You can lock a file so that people who are not enrolled in your course cannot access that file.")}
    From 8db7b0ce215d52cb09a520c1b2d96368126f7e24 Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 26 Feb 2014 09:26:50 -0500 Subject: [PATCH 4/4] Add test for external_url being passed to assets page. --- .../contentstore/views/tests/test_assets.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index 6384269715..8d7b2a9008 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -18,6 +18,7 @@ from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.django import loc_mapper +from django.test.utils import override_settings class AssetsTestCase(CourseTestCase): @@ -36,21 +37,15 @@ 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): - path = StaticContent.get_static_path_from_location(self.location) + location = Location(['i4x', 'foo', 'bar', 'asset', 'my_file_name.jpg']) + path = StaticContent.get_static_path_from_location(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( @@ -144,6 +139,7 @@ class AssetToJsonTestCase(AssetsTestCase): Unit test for transforming asset information into something we can send out to the client via JSON. """ + @override_settings(LMS_BASE="lms_base_url") def test_basic(self): upload_date = datetime(2013, 6, 1, 10, 30, tzinfo=UTC) @@ -155,6 +151,7 @@ class AssetToJsonTestCase(AssetsTestCase): self.assertEquals(output["display_name"], "my_file") self.assertEquals(output["date_added"], "Jun 01, 2013 at 10:30 UTC") self.assertEquals(output["url"], "/i4x/foo/bar/asset/my_file_name.jpg") + self.assertEquals(output["external_url"], "lms_base_url/i4x/foo/bar/asset/my_file_name.jpg") self.assertEquals(output["portable_url"], "/static/my_file_name.jpg") self.assertEquals(output["thumbnail"], "/i4x/foo/bar/asset/my_file_name_thumb.jpg") self.assertEquals(output["id"], output["url"])