Commit f06c67ef by Lyla Fischer Committed by Calen Pennington

added embeddable links

parent 0bd5446f
...@@ -698,8 +698,9 @@ def upload_asset(request, org, course, coursename): ...@@ -698,8 +698,9 @@ def upload_asset(request, org, course, coursename):
# timestamp populated, but we might as well wait for the first real request to come in # timestamp populated, but we might as well wait for the first real request to come in
# to re-populate the cache. # to re-populate the cache.
del_cached_content(content.location) del_cached_content(content.location)
response = HttpResponse('Upload completed')
return HttpResponse('Upload completed') response['asset_url'] = StaticContent.get_url_path_from_location(file_location)
return response
''' '''
This view will return all CMS users who are editors for the specified course This view will return all CMS users who are editors for the specified course
......
...@@ -23,6 +23,10 @@ $(document).ready(function() { ...@@ -23,6 +23,10 @@ $(document).ready(function() {
$modalCover.bind('click', hideHistoryModal); $modalCover.bind('click', hideHistoryModal);
$('.assets .upload-button').bind('click', showUploadModal); $('.assets .upload-button').bind('click', showUploadModal);
$('.upload-modal .close-button').bind('click', hideModal); $('.upload-modal .close-button').bind('click', hideModal);
$('a.show-xml').toggle(showEmbeddableXML, hideEmbeddableXML);
$('a.copy-button').toggle(showEmbeddableXML, hideEmbeddableXML);
$('.unit .item-actions .delete-button').bind('click', deleteUnit); $('.unit .item-actions .delete-button').bind('click', deleteUnit);
$('.new-unit-item').bind('click', createNewUnit); $('.new-unit-item').bind('click', createNewUnit);
$('.save-subsection').bind('click', saveSubsection); $('.save-subsection').bind('click', saveSubsection);
...@@ -72,6 +76,17 @@ function removePolicyMetadata(e) { ...@@ -72,6 +76,17 @@ function removePolicyMetadata(e) {
_parent_el.remove(); _parent_el.remove();
else else
_parent_el.appendTo("#policy-to-delete"); _parent_el.appendTo("#policy-to-delete");
function showEmbeddableXML(e) {
$ceiling = $(this).parents('tr');
if ($ceiling.length === 0) $ceiling = $(this).parents('.upload-modal');
$ceiling.find('.embeddable-xml').html('<img src="'+$(this).attr('href')+'"/>');
}
function hideEmbeddableXML(e) {
$ceiling = $(this).parents('tr');
console.log($ceiling.length)
if ($ceiling.length === 0) $ceiling = $(this).parents('.upload-modal');
$ceiling.find('.embeddable-xml').html("");
} }
...@@ -258,6 +273,7 @@ function displayFinishedUpload(xhr) { ...@@ -258,6 +273,7 @@ function displayFinishedUpload(xhr) {
if(xhr.status = 200){ if(xhr.status = 200){
markAsLoaded(); markAsLoaded();
} }
$('.upload-modal .copy-button').attr('href', xhr.getResponseHeader('asset_url'));
$('.upload-modal .progress-fill').html(xhr.responseText); $('.upload-modal .progress-fill').html(xhr.responseText);
$('.upload-modal .choose-file-button').html('Load Another File').show(); $('.upload-modal .choose-file-button').html('Load Another File').show();
} }
......
...@@ -86,6 +86,9 @@ ...@@ -86,6 +86,9 @@
} }
} }
} }
.show-xml {
@include blue-button;
}
} }
.upload-modal { .upload-modal {
......
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
</td> </td>
<td class="name-col"> <td class="name-col">
<a href="${asset['url']}" class="filename">${asset['displayname']}</a> <a href="${asset['url']}" class="filename">${asset['displayname']}</a>
<div class="embeddable-xml"></div>
</td> </td>
<td class="date-col"> <td class="date-col">
${asset['uploadDate']} ${asset['uploadDate']}
</td> </td>
<td class="embed-col"> <td class="embed-col">
<a href="${asset['url']}">copy</a> <a class="show-xml" href="${asset['url']}">XML</a>
</td> </td>
</tr> </tr>
% endfor % endfor
...@@ -64,8 +65,10 @@ ...@@ -64,8 +65,10 @@
<div class="progress-bar"> <div class="progress-bar">
<div class="progress-fill"></div> <div class="progress-fill"></div>
</div> </div>
<a href="#" class="copy-button">Copy Embed Link</a> <div class="embeddable-xml"></div>
<form class="file-chooser" action="${upload_asset_callback_url}" method="post" enctype="multipart/form-data"> <a href="#" class="copy-button">Show Embeddable XML</a>
<form class="file-chooser" action="${upload_asset_callback_url}"
method="post" enctype="multipart/form-data">
<a href="#" class="choose-file-button">Choose File</a> <a href="#" class="choose-file-button">Choose File</a>
<input type="file" class="file-input" name="file"> <input type="file" class="file-input" name="file">
</form> </form>
......
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