{% extends "richie/fullwidth.html" %}
{% load cms_tags i18n extra_tags menu_tags %}

{% block head_title %}{% spaceless %}
  {% page_attribute "page_title" as course_run_title %}
  {% page_attribute "page_title" current_page.parent_page as course_title %}
  {{ course_run_title|capfirst }} - {{ course_title|capfirst }}
{% endspaceless %}{% endblock head_title %}

{# Make sure the course run pages are not indexed by search engines #}
{% block meta_index_rules %}<meta name="robots" content="noindex">{% endblock meta_index_rules %}

{% block meta_opengraph_contextuals %}
    {% page_attribute "page_title" as course_run_title %}
    {% page_attribute "page_title" current_page.parent_page as course_title %}
    <meta property="og:title" content="{{ course_run_title|capfirst }} - {{ course_title|capfirst|truncatechars:53 }}">
    <meta property="og:url" content="{{ SITE.web_url }}{{ current_page.get_absolute_url }}">
{% endblock meta_opengraph_contextuals %}

{% block breadcrumbs %}
  <ul class="breadcrumbs">
    {% block breadcrumbs_content %}
      {% show_breadcrumb 0 "courses/cms/fragment_course_run_breadcrumb.html" %}
    {% endblock breadcrumbs_content %}
  </ul>
{% endblock breadcrumbs %}

{% block content %}{% spaceless %}
<div class="course-detail">

  {% with course_run=current_page.courserun header_level=2 %}

  <div class="course-detail__content course-detail__content--one">
    <h1 class="course-detail__content__title">
      {% if request.current_page.parent_page.parent_page.course %}
        {{ current_page.parent_page.parent_page.get_title }}
      {% else %}
        {{ current_page.parent_page.get_title }}
      {% endif %}
      <br />
      {% render_model request.current_page "title" %}
    </h1>

    <div class="course-detail__content__row course-detail__content__categories">
      {% with variant="tag" %}
        {% show_placeholder "course_categories" current_page.parent_page %}
      {% endwith %}
    </div>

    <div class="course-detail__content__run">
      <h2 class="course-detail__content__run__title">{% trans 'Details' %}</h2>
      <div class="course-detail__content__run__block">
        <dl>
          <dt>{% trans "Enrollment starts" %}</dt>
          <dd>{% render_model course_run "enrollment_start" "enrollment_start,enrollment_end" "" "date:'DATE_FORMAT'|default:'...'" %}</dd>
          <dt>{% trans "Enrollment ends" %}</dt>
          <dd>{% render_model course_run "enrollment_end" "enrollment_start,enrollment_end" "" "date:'DATE_FORMAT'|default:'...'" %}</dd>
        </dl>
      </div>
      <div class="course-detail__content__run__block">
        <dl>
          <dt>{% trans "Course starts" %}</dt>
          <dd>{% render_model course_run "start" "start,end" "" "date:'DATE_FORMAT'|default:'...'" %}</dd>
          <dt>{% trans "Course ends" %}</dt>
          <dd>{% render_model course_run "end" "start,end" "" "date:'DATE_FORMAT'|default:'...'" %}</dd>
        </dl>
      </div>
      <div class="course-detail__content__run__block">
        <dl>
          <dt>{% trans "Languages" %}</dt>
          <dd>{% render_model course_run "get_languages_display" "languages" %}</dd>
        </dl>
        {% if course_run.state.call_to_action %}
        <a class="course-detail__content__run__block__cta" href="{{ course_run.resource_link }}">
          {{ course_run.state.call_to_action|capfirst }}
        </a>
        {% else %}
        <button class="course-detail__content__run__block__cta course-detail__content__run__block__cta--projected">
          {{ course_run.state.text|capfirst }}
        </button>
        {% endif %}
      </div>
      {% if current_page.publisher_is_draft %}
      <dl class="course-detail__content__run__block course-detail__content__run__block--full">
        <dt>{% trans "Resource link" %}</dt>
        <dd>
          <a href="{{ course_run.resource_link }}">
            {% render_model course_run "resource_link" "resource_link" "" "default:'...'" %}
          </a>
        </dd>
      </dl>
      {% endif %}
    </div>

    {% block teaser %}
    <div class="course-detail__content__row course-detail__content__teaser">
      {% show_placeholder "course_teaser" current_page.parent_page %}
    </div>
    {% endblock teaser %}

    {% block description %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_description" %}
    <section class="course-detail__content__row course-detail__content__description">
      <h2 class="course-detail__content__row__title">{% trans 'About the course' %}</h2>
      {% with header_level=3 %}
        {% show_placeholder "course_description" current_page.parent_page %}
      {% endwith %}
    </section>
    {% endif %}
    {% endblock description %}

    {% block skills %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_skills" %}
    <div class="course-detail__content__row course-detail__content__skills">
      <h2 class="course-detail__content__row__title">{% trans "What you will learn" %}</h2>
      <p>{% trans "At the end of this course, you will be able to:" %}</p>
      {% show_placeholder "course_skills" current_page.parent_page %}
    </div>
    {% endif %}
    {% endblock skills %}

    {% block format %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_format" %}
    <section class="course-detail__content__row course-detail__content__format">
      <h2 class="course-detail__content__row__title">{% trans 'Format' %}</h2>
      {% show_placeholder "course_format" current_page.parent_page %}
    </section>
    {% endif %}
    {% endblock format %}

    {% block prerequisites %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_prerequisites" %}
    <section class="course-detail__content__row course-detail__content__prerequisites">
      <h2 class="course-detail__content__row__title">{% trans 'Prerequisites' %}</h2>
      {% show_placeholder "course_prerequisites" current_page.parent_page %}
    </section>
    {% endif %}
    {% endblock prerequisites %}

    {% block plan %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_plan" %}
    <section class="course-detail__content__row course-detail__content__plan">
      <h2 class="course-detail__content__row__title">{% trans 'Course plan' %}</h2>
      {% show_placeholder "course_plan" current_page.parent_page %}
    </section>
    {% endif %}
    {% endblock plan %}

    {% block assessment %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_assessment" %}
    <section class="course-detail__content__row course-detail__content__assessment">
      <h2 class="course-detail__content__row__title">{% trans 'Assessment and certification' %}</h2>
      {% show_placeholder "course_assessment" current_page.parent_page %}
    </section>
    {% endif %}
    {% endblock assessment %}

    {% block organizations %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_organizations" %}
    <section class="section course-detail__content__row course-detail__content__organizations">
      <h2 class="section__title course-detail__content__row__title course-detail__content__organizations__title">
        {% trans 'Organizations' %}
      </h2>
      <div class="section__items course-detail__content__organizations__items">
        {% show_placeholder "course_organizations" current_page.parent_page %}
      </div>
    </section>
    {% endif %}
    {% endblock organizations %}

    {% block team %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_team" %}
    <section class="section course-detail__content__row course-detail__content__team">
      <h2 class="section.title course-detail__content__row__title course-detail__content__team__title">
        {% trans 'Course team' %}
      </h2>
      {% with header_level=3 %}
        <div class="section__items course-detail__content__team__items">
          {% show_placeholder "course_team" current_page.parent_page %}
        </div>
      {% endwith %}
    </section>
    {% endif %}
    {% endblock team %}

    {% block information %}
    {% if not current_page.parent_page|is_empty_placeholder:"course_information" %}
    <div class="course-detail__content__row course-detail__content__information">
      {% show_placeholder "course_information" current_page.parent_page %}
    </div>
    {% endif %}
    {% endblock information %}

    {% block licenses %}
    <section class="course-detail__content__row course-detail__content__license">
      <h2 class="course-detail__content__row__title course-detail__content__license__title">{% trans 'License' %}</h2>

      <div class="course-detail__content__license__item">
        <h3 class="course-detail__content__license__item__title">{% trans 'License for the course content' %}</h3>
        {% with header_level=4 %}
          {% show_placeholder "course_license_content" current_page.parent_page %}
        {% endwith %}
      </div>

      <div class="course-detail__content__license__item">
        <h3 class="course-detail__content__license__item__title">{% trans 'License for the content created by course participants' %}</h3>
        {% with header_level=4 %}
          {% show_placeholder "course_license_participation" current_page.parent_page %}
        {% endwith %}
      </div>
    </section>
    {% endblock licenses %}

  </div>
  {% endwith %}

</div>
{% endspaceless %}{% endblock content %}
