<%page args="course, enrollment, show_courseware_link, cert_status, show_email_settings, course_mode_info, show_refund_option" />

<%! from django.utils.translation import ugettext as _ %>
<%!
  from django.core.urlresolvers import reverse
  from courseware.courses import course_image_url, get_course_about_section
  import waffle
%>

<%namespace name='static' file='../static_content.html'/>

<li class="course-item">
  <article class="course ${enrollment.mode}">
    <%
      if waffle.flag_is_active(request, 'merge_course_tabs'):
          course_target = reverse('courseware', args=[course.id])
      else:
          course_target = reverse('info', args=[course.id])
    %>

    % if show_courseware_link:
      <a href="${course_target}" class="cover">
        <img src="${course_image_url(course)}" alt="${_('{course_number} {course_name} Cover Image').format(course_number=course.number, course_name=course.display_name_with_default) |h}" />
      </a>
    % else:
      <div class="cover">
        <img src="${course_image_url(course)}" alt="${_('{course_number} {course_name} Cover Image').format(course_number=course.number, course_name=course.display_name_with_default) | h}" />
      </div>
    % endif

    % if enrollment.mode == "verified":
      <span class="sts-enrollment">
        <span class="label">${_("Enrolled as: ")}</span>
        <img class="deco-graphic" src="${static.url('images/vcert-ribbon-s.png')}" alt="ID Verified Ribbon/Badge" />
        <span class="sts-enrollment-value">${_("ID Verified")}</span>
      </span>
    % endif

    <section class="info">
      <hgroup>
        <p class="date-block">
        % if course.has_ended():
        ${_("Course Completed - {end_date}").format(end_date=course.end_date_text)}
        % elif course.has_started():
        ${_("Course Started - {start_date}").format(start_date=course.start_date_text)}
        % else:   # hasn't started yet
        ${_("Course Starts - {start_date}").format(start_date=course.start_date_text)}
        % endif
        </p>
        <h2 class="university">${get_course_about_section(course, 'university')}</h2>
        <h3>
          % if show_courseware_link:
            <a href="${course_target}">${course.display_number_with_default | h} ${course.display_name_with_default}</a>
          % else:
            <span>${course.display_number_with_default | h} ${course.display_name_with_default}</span>
          % endif
        </h3>
      </hgroup>

      % if course.has_ended() and cert_status and not enrollment.mode == 'audit':
      <%include file='_dashboard_certificate_information.html' args='cert_status=cert_status,course=course, enrollment=enrollment'/>
      % endif

      %if course_mode_info['show_upsell']:
        <div class="message message-upsell has-actions is-expandable is-shown">

            <div class="wrapper-tip">
              <h4 class="message-title">
                <i class="icon-caret-down ui-toggle-expansion"></i>
                <span class="value">${_("Challenge Yourself!")}</span>
              </h4>
              <p class="message-copy">${_("Take this course as an ID-verified student.")}</p>
            </div>

            <div class="wrapper-extended">
                <p class="message-copy">${_("You can still sign up for an ID verified certificate for this course. If you plan to complete the whole course, it is a great way to recognize your achievement. {a_start}Learn more about verified certificates{a_end}.").format(a_start='<a href="{}">'.format(marketing_link('WHAT_IS_VERIFIED_CERT')), a_end="</a>")}</p>

              <ul class="actions message-actions">
                <li class="action-item">
                  <a class="action action-upgrade" href="${reverse('course_modes_choose', kwargs={'course_id': course.id})}?upgrade=True">
                    <img class="deco-graphic" src="${static.url('images/vcert-ribbon-s.png')}" alt="ID Verified Ribbon/Badge">
                    <span class="wrapper-copy">
                      <span class="copy">${_("Upgrade to Verified Track")}</span>
                    </span>
                  </a>
                </li>
              </ul>
            </div>
        </div>
      %endif

      % if show_courseware_link:
        % if course.has_ended():
          <a href="${course_target}" class="enter-course archived">${_('View Archived Course')}</a>
        % else:
          <a href="${course_target}" class="enter-course">${_('View Course')}</a>
        % endif
      % endif

      % if enrollment.mode != "verified":
      <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}" onclick="document.getElementById('track-info').innerHTML='Are you sure you want to unregister from'; document.getElementById('refund-info').innerHTML=''">${_('Unregister')}</a>
      % elif show_refund_option:
      <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}" onclick="document.getElementById('track-info').innerHTML='Are you sure you want to unregister from the verified certificate track of'; document.getElementById('refund-info').innerHTML=gettext('You will be refunded the amount you paid.')">${_('Unregister')}</a>
      % else:
      <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}" onclick="document.getElementById('track-info').innerHTML='Are you sure you want to unregister from the verified certificate track of'; document.getElementById('refund-info').innerHTML=gettext('The refund deadline for this course has passed, so you will not receive a refund.')">${_('Unregister')}</a>
      % endif

% if show_email_settings:
        <a href="#email-settings-modal" class="email-settings" rel="leanModal" data-course-id="${course.id}" data-course-number="${course.number}" data-optout="${course.id in course_optouts}">${_('Email Settings')}</a>
% endif



  </section>
</article>
</li>
