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

{% block content %}{% spaceless %}
{% with organization=current_page.organization header_level=2 %}
<div class="organization-detail">
  <div class="organization-detail__banner">
    {% get_placeholder_plugins "banner" as plugins or %}
      <div class="organization-detail__banner__empty">{% trans "Banner" %}</div>
    {% endget_placeholder_plugins %}
    {% blockplugin plugins.0 %}
      <img
        src="{% thumbnail instance.picture 1140x400 crop upscale subject_location=instance.picture.subject_location %}"
        srcset="
          {% thumbnail instance.picture 1140x400 crop upscale subject_location=instance.picture.subject_location %} 1140w,
          {% if instance.picture.width >= 2280 %}{% thumbnail instance.picture 2280x800 crop upscale subject_location=instance.picture.subject_location %} 2280w,{% endif %}
          {% if instance.picture.width >= 3420 %}{% thumbnail instance.picture 3420x600 crop upscale subject_location=instance.picture.subject_location %} 3420w{% endif %}
        "
        sizes="1140px"
        alt="{% if instance.picture.default_alt_text %}{{ instance.picture.default_alt_text }}{% else %}{% trans 'organization banner' %}{% endif %}"
      />
    {% endblockplugin %}
  </div>

  <div class="organization-detail__logo">
    {% get_placeholder_plugins "logo" as plugins or %}
      <div class="organization-detail__logo__empty">{% trans "Logo" %}</div>
    {% endget_placeholder_plugins %}
    {% blockplugin plugins.0 %}
      <img
        src="{% thumbnail instance.picture 300x300 crop upscale subject_location=instance.picture.subject_location %}"
        srcset="
          {% thumbnail instance.picture 300x300 crop upscale subject_location=instance.picture.subject_location %} 300w,
          {% if instance.picture.width >= 600 %}{% thumbnail instance.picture 600x600 crop upscale subject_location=instance.picture.subject_location %} 600w,{% endif %}
          {% if instance.picture.width >= 900 %}{% thumbnail instance.picture 900x900 crop upscale subject_location=instance.picture.subject_location %} 900w{% endif %}
        "
        sizes="300px"
        alt="{% if instance.picture.default_alt_text %}{{ instance.picture.default_alt_text }}{% else %}{% trans 'organization logo' %}{% endif %}"
      />
    {% endblockplugin %}
  </div>

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

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

{% with courses=organization.get_courses %}
  {% if courses %}
  <div class="course-glimpse-list">
    <h2 class="course-glimpse-list__title">{% trans "Related courses" %}</h2>
    {% for course in courses %}
      {% if course.extended_object.publisher_is_draft is True %}
        <a class="course-glimpse course-glimpse--link course-glimpse--draft" href="{{ course.extended_object.get_absolute_url }}">
          {% include "courses/cms/fragment_course_glimpse.html" %}
        </a>
      {% 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" %}
        </a>
      {% endif %}
    {% endfor %}
    </div>
  {% endif %}
{% endwith %}

{% with persons=organization.get_persons %}
  {% if persons %}
  <div class="person-glimpse-list">
    <h2 class="person-glimpse-list__title">{% trans "Related persons" %}</h2>
    {% for person in persons %}
      {% if person.extended_object.publisher_is_draft %}
        {% include "courses/cms/fragment_person_glimpse.html" %}
      {% elif person.check_publication %}
        {% include "courses/cms/fragment_person_glimpse.html" %}
      {% endif %}
    {% endfor %}
  </div>
  {% endif %}
{% endwith %}

{% endwith %}
{% endspaceless %}{% endblock content %}
