{% extends "core/base.jinja" %}

{%- block additional_css -%}
  <link rel="stylesheet" href="{{ static('sas/css/album.scss') }}">
{%- endblock -%}

{% block title %}
  {% trans %}SAS{% endtrans %}
{% endblock %}

{% block description -%}
  {% trans %}See all the photos taken during events organised by the AE.{% endtrans %}
{%- endblock %}

{% block metatags %}
  <meta property="og:url" content="{{ request.build_absolute_uri() }}" />
  <meta property="og:type" content="website" />
  <meta property="og:title" content="Stock à souvenirs" />
  <meta
    property="og:description"
    content="Retrouvez toutes les photos prises durant les événements organisés par l'AE."
  />
  <meta property="og:image" content="{{ request.build_absolute_uri(static("core/img/logo_no_text.png")) }}" />
{% endblock %}

{% set is_sas_admin = user.is_root or user.is_in_group(pk=settings.SITH_GROUP_SAS_ADMIN_ID) %}

{% from "sas/macros.jinja" import display_album %}

{% block content %}
  <main>
    <h3>{% trans %}SAS{% endtrans %}</h3>

    {% if not user.is_authenticated %}
      <p>{% trans %}You must be logged in to see the SAS.{% endtrans %}</p>
    {% else %}
      <br>
      <h4>{% trans %}Latest albums{% endtrans %}</h4>

      <div class="albums">
        {% for a in latest %}
          {{ display_album(a, edit_mode=False) }}
        {% endfor %}
      </div>

      <br>

      {% if is_sas_admin %}
        <form action="" method="post" enctype="multipart/form-data">
          {% csrf_token %}

          <div class="navbar">
            <h4>{% trans %}All categories{% endtrans %}</h4>
          </div>

          {% if clipboard %}
            <div class="clipboard">
              {% trans %}Clipboard: {% endtrans %}
              <ul>
                {% for f in clipboard %}
                  <li>{{ f.get_full_path() }}</li>
                {% endfor %}
              </ul>
              <input name="clear" type="submit" value="{% trans %}Clear clipboard{% endtrans %}">
            </div>
          {% endif %}
      {% else %}
        <h4>{% trans %}All categories{% endtrans %}</h4>
      {% endif %}

      <div class="albums">
        {% for a in categories %}
          {{ display_album(a, edit_mode=False) }}
        {% endfor %}
      </div>

      {% if album_create_fragment %}
        </form>
        <br>
        {{ album_create_fragment }}
      {% endif %}
    {% endif %}
  </main>
{% endblock %}
