{% extends "agenda_culturel/page.html" %}

{% block title %}{% block og_title %}Liste des organismes{% endblock %}{% endblock %}

{% block fluid %}{% endblock %}

{% load utils_extra %}
{% load cat_extra %}
{% block entete_header %}
    {% css_categories %}
{% endblock %}

{% block sidemenu-bouton %}
    <li><a href="#contenu-principal" aria-label="Aller au contenu">{% picto_from_name "chevron-up" %}</a></li>
    <li><a href="#sidebar" aria-label="Aller au menu latéral">{% picto_from_name "chevron-down" %}</a></li>
{% endblock %}

{% block content %}
<article>
    <header>
        {% if user.is_authenticated %}
        <div class="slide-buttons">
            <a href="{% url 'add_organisation' %}" role="button">Ajouter {% picto_from_name "plus-circle" %}</a>
        </div>
        {% endif %}
        <h1>Liste des organismes</h1>
    </header>
    {% include "agenda_culturel/navigation.html" with page_obj=page_obj %}
</article>

    {% if object_list %}
      {% for organisation in object_list %}
      <article>
        <header>
            {% if user.is_authenticated %}
            <div class="slide-buttons">
                <a href="{% url 'edit_organisation' organisation.pk %}" role="button">Modifier {% picto_from_name "edit-3" %}</a>
                <a href="{% url 'delete_organisation' organisation.pk %}" role="button">Supprimer {% picto_from_name "trash-2" %}</a>
            </div>
            {% endif %}
            <h2>{{ organisation.name }}</h2>
        </header>
        {% if organisation.website or organisation.principal_place %}
        <ul>
            {% if organisation.website %}
            <li><strong>Site internet&nbsp;:</strong> <a href="{{ organisation.website }}">{{ organisation.website }}</a></li>
            {% endif %}
            {% if organisation.principal_place %}
            <li><strong>Lieu principal&nbsp;:</strong> <a href="{{ organisation.principal_place.get_absolute_url }}">{{ organisation.principal_place }}</a></li>
            {% endif %}
        </ul>
        {% endif %}
        
        <footer>
            {% if organisation.organised_events.all|length > 1 %}
            <p class="slide-buttons"><a role="button" href="{{ organisation.get_absolute_url }}">voir les {{ organisation.organised_events.all|length }} événements {% picto_from_name "chevron-right" %}</a></p>
            {% else %}
            <p  class="slide-buttons"><a role="button" href="{{ organisation.get_absolute_url }}">voir les détails {% picto_from_name "chevron-right" %}</a></p>
            {% endif %}
            <div style="clear: both"></div>
        </footer>
      </article>
      {% endfor %}
    {% else %}
        <p>Il n'y a aucun organisme défini.</p>
    {% endif %}

<article>
    <footer>
        {% include "agenda_culturel/navigation.html" with page_obj=page_obj %}
     </footer>

</article>


{% endblock %}