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

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

<%
  cert_name_short = course.cert_name_short
  if cert_name_short == "":
    cert_name_short = settings.CERT_NAME_SHORT

  cert_name_long = course.cert_name_long
  if cert_name_long == "":
    cert_name_long = settings.CERT_NAME_LONG
  billing_email = settings.PAYMENT_SUPPORT_EMAIL
%>

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

<li class="course-item">
  % if settings.FEATURES.get('ENABLE_VERIFIED_CERTIFICATES'):
    <article class="course ${enrollment.mode}">
  % else:
    <article class="course">
  %endif
    <%
      course_target = reverse('info', args=[course.id.to_deprecated_string()])
    %>

    % if show_courseware_link:
      % if not is_course_blocked:
        <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:
        <a class="fade-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>
        % endif
    % 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 settings.FEATURES.get('ENABLE_VERIFIED_CERTIFICATES'):
        % if enrollment.mode == "verified":
          <span class="sts-enrollment" title="${_("You're enrolled as a verified student")}">
            <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">${_("Verified")}</span>
          </span>
        % elif enrollment.mode == "honor":
          <span class="sts-enrollment" title="${_("You're enrolled as an honor code student")}">
            <span class="label">${_("Enrolled as: ")}</span>
            <span class="sts-enrollment-value">${_("Honor Code")}</span>
          </span>
        % elif enrollment.mode == "audit":
          <span class="sts-enrollment" title="${_("You're auditing this course")}">
            <span class="label">${_("Enrolled as: ")}</span>
            <span class="sts-enrollment-value">${_("Auditing")}</span>
          </span>
        % elif enrollment.mode == "professional":
          <span class="sts-enrollment" title="${_("You're enrolled as a professional education student")}">
          <span class="label">${_("Enrolled as: ")}</span>
          <span class="sts-enrollment-value">${_("Professional Ed")}</span>
        </span>
        % endif
    % endif

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

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

      % if course_mode_info['show_upsell'] and not is_course_blocked:
        <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 {cert_name_long} for this course. If you plan to complete the whole course, it is a great way to recognize your achievement. {link_start}Learn more about the verified {cert_name_long}{link_end}.").format(link_start='<a href="{}">'.format(marketing_link('WHAT_IS_VERIFIED_CERT')), link_end="</a>", cert_name_long=cert_name_long)}</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.to_deprecated_string()})}?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" id="upgrade-to-verified" data-course-id="${course.id | h}" data-user="${user.username | h}">${_("Upgrade to Verified Track")}</span>
                    </span>
                  </a>
                </li>
              </ul>
            </div>
        </div>
      %endif
      % if is_course_blocked:
        <p id="block-course-msg" class="course-block">
            ${_('You can no longer access this course because payment has not yet been received. you can <a href="#">contact the account holder</a> to request payment, or you can')}
            <a id="unregister_block_course" rel="leanModal" data-course-id="${course.id | h}" data-course-number="${course.number | h}" href="#unenroll-modal" > ${_('unenroll')} </a>
            ${_('for this course.')}
        </p>
      %endif

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

      % if is_paid_course and show_refund_option:
        ## Translators: The course's name will be added to the end of this sentence.
        % if not is_course_blocked:
        <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the purchased course")}';
        document.getElementById('refund-info').innerHTML=gettext('You will be refunded the amount you paid.')">
          ${_('Unenroll')}
        </a>
        % else:
        <a class="disable-look-unregister" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the purchased course")}';
        document.getElementById('refund-info').innerHTML=gettext('You will be refunded the amount you paid.')">
          ${_('Unenroll')}
        </a>
        % endif
      % elif is_paid_course and not show_refund_option:
        ## Translators: The course's name will be added to the end of this sentence.
        % if not is_course_blocked:
        <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the purchased course")}';
        document.getElementById('refund-info').innerHTML=gettext('You will not be refunded the amount you paid.')">
          ${_('Unenroll')}
        </a>
        % else:
        <a class="disable-look-unregister" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the purchased course")}';
        document.getElementById('refund-info').innerHTML=gettext('You will not be refunded the amount you paid.')">
          ${_('Unenroll')}
        </a>
        % endif
      % elif enrollment.mode != "verified":
        ## Translators: The course's name will be added to the end of this sentence.
        % if not is_course_blocked:
        <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from")}'; document.getElementById('refund-info').innerHTML=''">
          ${_('Unenroll')}
        </a>
        % else:
        <a class="disable-look-unregister" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from")}'; document.getElementById('refund-info').innerHTML=''">
          ${_('Unenroll')}
        </a>
        % endif
      % elif show_refund_option:
        ## Translators: The course's name will be added to the end of this sentence.
        % if not is_course_blocked:
        <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the verified {cert_name_long} track of").format(cert_name_long=cert_name_long)}';
        document.getElementById('refund-info').innerHTML=gettext('You will be refunded the amount you paid.')">
          ${_('Unenroll')}
        </a>
        % else:
        <a class="disable-look-unregister" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the verified {cert_name_long} track of").format(cert_name_long=cert_name_long)}';
        document.getElementById('refund-info').innerHTML=gettext('You will be refunded the amount you paid.')">
          ${_('Unenroll')}
        </a>
        % endif
      % else:
        ## Translators: The course's name will be added to the end of this sentence.
        % if not is_course_blocked:
        <a href="#unenroll-modal" class="unenroll" rel="leanModal" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the verified {cert_name_long} track of").format(cert_name_long=cert_name_long)}';
        document.getElementById('refund-info').innerHTML=gettext('The refund deadline for this course has passed, so you will not receive a refund.')">
          ${_('Unenroll')}
        </a>
        % else:
        <a class="disable-look-unregister" data-course-id="${course.id | h}" data-course-number="${course.number | h}" onclick="document.getElementById('track-info').innerHTML='${_("Are you sure you want to unenroll from the verified {cert_name_long} track of").format(cert_name_long=cert_name_long)}';
        document.getElementById('refund-info').innerHTML=gettext('The refund deadline for this course has passed, so you will not receive a refund.')">
          ${_('Unenroll')}
        </a>
        % endif
      % endif

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



  </section>
</article>
</article>
</li>
 <script>
           $( document ).ready(function() {

               if("${is_course_blocked}" == "True"){
                   $( "#unregister_block_course" ).click(function() {
                       $('.disable-look-unregister').click();
                   });
               }
           });
 </script>
