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

{% block content %}{% spaceless %}
{% with organization=current_page.organization header_level=2 %}
<div class="organization-detail">
  <div class="organization-detail__banner">
    {% placeholder "banner" %}
  </div>

  <div class="organization-detail__logo">
    {% with width=216 height=120 %}
      {% placeholder "logo" or %}
        <img src="{% static "images/samples/main-organization.png" %}" alt="">
      {% endplaceholder %}
    {% endwith %}
  </div>

  <h1 class="organization-detail__title">{% render_model request.current_page "titles" %}</h1>

  <div class="organization-detail__content">
    <div class="organization-detail__content__description">
      {% placeholder "description" %}
    </div>
  </div>
</div>

<div class="course-glimpse-list">
  {% for course in organization.get_courses %}

    {# If the current page is a draft, show draft courses with a class annotation for styling #}
    {% if current_page.publisher_is_draft %}
      {% if course.check_publication is True %}
      <a class="course-glimpse course-glimpse--link" href="{{ course.public_extension.extended_object.get_absolute_url }}">
        {% include "courses/cms/fragment_course_glimpse.html" with course=course.public_extension %}
      </a>
      {% else %}
      <a class="course-glimpse course-glimpse--link course-glimpse--draft" href="{{ course.extended_object.get_absolute_url }}">
        {% include "courses/cms/fragment_course_glimpse.html" with course=course %}
      </a>
      {% endif %}
    {# If the current course page is the published version, show only the courses that are published #}
    {% elif course.check_publication is True %}
      <a class="course-glimpse course-glimpse--link" href="{{ course.extended_object.get_absolute_url }}">
        {% include "courses/cms/fragment_course_glimpse.html" with course=course.public_extension %}
      </a>
    {% endif %}
  {% empty %}
    <p class="course-glimpse course-glimpse--empty">
      {% trans "No associated courses" %}
    </p>
  {% endfor %}
</div>
{% endwith %}
{% endspaceless %}{% endblock content %}
