Merge pull request #2579 from edx/giulio/studio-file-urls

Internal/External Studio file URLs
This commit is contained in:
Giulio Gratta
2014-02-26 09:32:59 -08:00
8 changed files with 26 additions and 6 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

@@ -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):
@@ -138,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)
@@ -149,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"])

View File

@@ -8,6 +8,7 @@ define(["backbone"], function(Backbone) {
thumbnail: "",
date_added: "",
url: "",
external_url: "",
portable_url: "",
locked: false
}

View File

@@ -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
}));

View File

@@ -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;

View File

@@ -156,11 +156,19 @@ require(["domReady", "jquery", "js/models/asset", "js/collections/asset",
<p>${_("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.")}</p>
</div>
<div class="bit">
<h3 class="title-3">${_("File URLs")}</h3>
<ul class="list-details">
<li class="item-detail">${_("You use the Embed URL value to link to the file or image from a component, a course update, or a course handout.")}</li>
<li class="item-detail">${_("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.")}</li>
</ul>
</div>
<div class="bit">
<h3 class="title-3">${_("What can I do on this page?")}</h3>
<ul class="list-details">
<li class="item-detail">${_("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.")}</li>
<li class="item-detail">${_("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.")}</li>
</ul>
<li class="item-detail">${_("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.")}</li>
</ul>
</div>
</aside>
</section>

View File

@@ -16,7 +16,8 @@
<th class="thumb-col"><%= gettext("Preview") %></th>
<th class="name-col sortable-column"><span class="column-sort-link" id="js-asset-name-col"><%= gettext("Name") %></span></th>
<th class="date-col sortable-column"><span class="column-sort-link" id="js-asset-date-col"><%= gettext("Date Added") %></span></th>
<th class="embed-col"><%= gettext("URL") %></th>
<th class="embed-col"><%= gettext("Embed URL") %></th>
<th class="embed-col"><%= gettext("External URL") %></th>
<th class="actions-col"><span class="sr"><%= gettext("Actions") %></span></th>
</tr>
</thead>

View File

@@ -16,6 +16,9 @@
<td class="embed-col">
<input type="text" class="embeddable-xml-input" value="<%= portable_url %>" readonly>
</td>
<td class="embed-col">
<input type="text" class="embeddable-xml-input" value="<%= external_url %>" readonly>
</td>
<td class="actions-col">
<ul class="actions-list">
<li class="action-item action-delete">
@@ -27,4 +30,4 @@
<div class="action-button"><i class="icon-lock"></i><i class="icon-unlock-alt"></i></div>
</li>
</ul>
</td>
</td>