Commit 9dffb63c by Clinton Blackburn

Added button to publish data to external services

LEARNER-2473
parent 22589de7
...@@ -49,6 +49,17 @@ ...@@ -49,6 +49,17 @@
</h2> </h2>
</div> </div>
<button class="btn btn-primary" onclick="publish('{% url 'publisher:api:v1:course_run-publish' pk=object.pk %}');">{% trans "Publish" %}</button>
<div class="alert hidden" role="alert" aria-labelledby="alertTitle" tabindex="-1" id="alertContainer" style="margin:15px 0;">
<span class="icon alert-icon fa" aria-hidden="true"></span>
<div class="alert-message-with-action">
<h3 class="sr-only alert-title" id="alertTitle"></h3>
<p class="alert-copy"></p>
</div>
</div>
{% include 'alert_messages.html' %} {% include 'alert_messages.html' %}
<div id="stateChangeAlert" class="alert-messages hidden"> <div id="stateChangeAlert" class="alert-messages hidden">
...@@ -107,10 +118,48 @@ ...@@ -107,10 +118,48 @@
<script src="{% static 'js/publisher/change-state.js' %}"></script> <script src="{% static 'js/publisher/change-state.js' %}"></script>
<script src="{% static 'js/publisher/modal-screen.js' %}"></script> <script src="{% static 'js/publisher/modal-screen.js' %}"></script>
<script> <script>
'use strict';
new Clipboard(".btn-copy", { new Clipboard(".btn-copy", {
text: function(trigger) { text: function(trigger) {
return $(trigger).parent().next('.copy').html().trim(); return $(trigger).parent().next('.copy').html().trim();
} }
}); });
function updateAlert(msg, isError) {
var $alertContainer = $('#alertContainer'),
alertClassToAdd = isError ? 'alert-error' : 'alert-success',
alertClassToRemove = isError ? 'alert-success' : 'alert-error',
iconClassToAdd = isError ? 'fa-warning' : 'fa-check',
iconClassToRemove = isError ? 'fa-check' : 'fa-warning';
$alertContainer.removeClass('hidden').removeClass(alertClassToRemove).addClass(alertClassToAdd);
$('.alert-icon', $alertContainer).removeClass(iconClassToRemove).addClass(iconClassToAdd);
$('.alert-title', $alertContainer).text(msg);
$('.alert-copy', $alertContainer).text(msg);
}
function showSuccessAlert(msg) {
updateAlert(msg, false);
}
function showFailureAlert(msg) {
updateAlert(msg, true);
}
function publish(url) {
$.ajax({
type: 'POST',
url: url,
contentType: 'application/json'
})
.done(function(data, textStatus, jqXHR) {
showSuccessAlert('{% trans 'Successfully published to Studio, E-Commerce, and Discovery.' %}');
})
.fail(function(jqXHR, textStatus, errorThrown) {
debugger;
showFailureAlert('{% trans 'Publication failed.' %}');
});
}
</script> </script>
{% endblock %} {% endblock %}
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-19 01:02-0400\n" "POT-Creation-Date: 2017-09-19 01:14-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -1050,6 +1050,7 @@ msgid "Accepted" ...@@ -1050,6 +1050,7 @@ msgid "Accepted"
msgstr "" msgstr ""
#: apps/publisher/templates/publisher/_approval_widget.html #: apps/publisher/templates/publisher/_approval_widget.html
#: apps/publisher/templates/publisher/course_run_detail/course_run_detail.html
msgid "Publish" msgid "Publish"
msgstr "" msgstr ""
...@@ -2467,6 +2468,14 @@ msgstr "" ...@@ -2467,6 +2468,14 @@ msgstr ""
msgid "DRUPAL" msgid "DRUPAL"
msgstr "" msgstr ""
#: apps/publisher/templates/publisher/course_run_detail/course_run_detail.html
msgid "Successfully published to Studio, E-Commerce, and Discovery."
msgstr ""
#: apps/publisher/templates/publisher/course_run_detail/course_run_detail.html
msgid "Publication failed."
msgstr ""
#: apps/publisher/templates/publisher/courses.html #: apps/publisher/templates/publisher/courses.html
msgid "Runs" msgid "Runs"
msgstr "" msgstr ""
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-09-19 01:02-0400\n" "POT-Creation-Date: 2017-09-19 01:14-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -1218,6 +1218,7 @@ msgid "Accepted" ...@@ -1218,6 +1218,7 @@ msgid "Accepted"
msgstr "Àççéptéd Ⱡ'σяєм ιρѕυм ∂#" msgstr "Àççéptéd Ⱡ'σяєм ιρѕυм ∂#"
#: apps/publisher/templates/publisher/_approval_widget.html #: apps/publisher/templates/publisher/_approval_widget.html
#: apps/publisher/templates/publisher/course_run_detail/course_run_detail.html
msgid "Publish" msgid "Publish"
msgstr "Püßlïsh Ⱡ'σяєм ιρѕυм #" msgstr "Püßlïsh Ⱡ'σяєм ιρѕυм #"
...@@ -2907,6 +2908,16 @@ msgstr "ÇÀT Ⱡ'σяєм#" ...@@ -2907,6 +2908,16 @@ msgstr "ÇÀT Ⱡ'σяєм#"
msgid "DRUPAL" msgid "DRUPAL"
msgstr "DRÛPÀL Ⱡ'σяєм ιρѕυ#" msgstr "DRÛPÀL Ⱡ'σяєм ιρѕυ#"
#: apps/publisher/templates/publisher/course_run_detail/course_run_detail.html
msgid "Successfully published to Studio, E-Commerce, and Discovery."
msgstr ""
"Süççéssfüllý püßlïshéd tö Stüdïö, É-Çömmérçé, änd Dïsçövérý. Ⱡ'σяєм ιρѕυм "
"∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: apps/publisher/templates/publisher/course_run_detail/course_run_detail.html
msgid "Publication failed."
msgstr "Püßlïçätïön fäïléd. Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт,#"
#: apps/publisher/templates/publisher/courses.html #: apps/publisher/templates/publisher/courses.html
msgid "Runs" msgid "Runs"
msgstr "Rüns Ⱡ'σяєм ι#" msgstr "Rüns Ⱡ'σяєм ι#"
......
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