<%! from django.utils.translation import ugettext as _ %>
<%inherit file="base.html" />
<%namespace name='static' file='static_content.html'/>

<%! from django.core.urlresolvers import reverse %>
<%block name="title">${_("Course Export")}</%block>
<%block name="bodyclass">is-signedin course tools export</%block>

<%block name="jsextra">
  % if in_err:
  <script type='text/javascript'>
    $(document).ready(function() {

      %if unit:
        var dialog = new CMS.Views.Prompt({
            title: gettext('There has been an error while exporting.'),
            message: gettext("There has been a failure to export to XML at least one component. It is recommended that you go to the edit page and repair the error before attempting another export. Please check that all components on the page are valid and do not display any error messages."),
            intent: "error",
            actions: {
                primary: {
                    text: gettext('Correct failed component'),
                    click: function(view) {
                        view.hide();
                        document.location = "${edit_unit_url}"
                    }
                },
                secondary: {
                    text: gettext('Return to Export'),
                    click: function(view) {
                        view.hide();
                    }
                }
            }
        });
      % else:
        var msg = "<p>" + gettext("There has been a failure to export your course to XML. Unfortunately, we do not have specific enough information to assist you in identifying the failed component. It is recommended that you inspect your courseware to identify any components in error and try again.") + "</p><p>" + gettext("The raw error message is:") + "</p>";
        msg = msg + "${raw_err_msg}";
        var dialog = new CMS.Views.Prompt({
            title: gettext('There has been an error with your export.'),
            message: msg,
            intent: "error",
            actions: {
                primary: {
                    text: gettext('Yes, take me to the main course page'),
                    click: function(view) {
                        view.hide();
                        document.location = "${course_home_url}"
                    }
                },
                secondary: {
                    text: gettext('Cancel'),
                    click: function(view) {
                        view.hide();
                    }
                }
            }
        });
      %endif
      dialog.show();
    })
  </script>
  %endif
</%block>

<%block name="content">
<div class="wrapper-mast wrapper">
  <header class="mast has-subtitle">
    <h1 class="page-header">
      <small class="subtitle">${_("Tools")}</small>
      <span class="sr">&gt; </span>${_("Course Export")}
    </h1>
  </header>
</div>

<div class="main-wrapper">
  <div class="inner-wrapper">

    <article class="export-overview">
      <div class="description">
        <h2>${_("About Exporting Courses")}</h2>
        ## Translators: ".tar.gz" is a file extension, and should not be translated
        <p>${_("When exporting your course, you will receive a .tar.gz formatted file that contains the following course data:")}</p>

        <ul>
          <li>${_("Course Structure (Sections and sub-section ordering)")}</li>
          <li>${_("Individual Units")}</li>
          <li>${_("Individual Problems")}</li>
          <li>${_("Static Pages")}</li>
          <li>${_("Course Assets")}</li>
        </ul>

        <p>${_("Your course export <strong>will not include</strong>: student data, forum/discussion data, course settings, certificates, grading information, or user data.")}</p>
      </div>

      <!-- default state -->
      <div class="export-form-wrapper">
        <form action="${reverse('generate_export_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}" method="post" enctype="multipart/form-data" class="export-form">
          <h2>${_("Export Course:")}</h2>

          <p class="error-block"></p>

          <a href="${reverse('generate_export_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}" class="button-export">${_("Download Files")}</a>
        </form>
      </div>

      <!-- download state: after user clicks download buttons -->
      <%doc>
      <div class="export-form-wrapper is-downloading">
        <form action="${reverse('export_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}" method="post" enctype="multipart/form-data" class="export-form">
          <h2>${_("Export Course:")}</h2>

          <p class="error-block"></p>

          <a href="#" class="button-export disabled">Files Downloading</a>
          <p class="message-status">${_("Download not start?")} <a href="#" class="text-export">${_("Try again")}</a></p>
        </form>
      </div>
      </%doc>
    </article>
  </div>
</div>
</%block>
