{% extends "gestion/base.html" %}
{% load static %}
{% load i18n %}
{% load autotranslate %}
{% load halflength %}
{% block titre %}{% trans "L'Ernestophone : répertoire" %}{% endblock %}
{% block content %}
<div id="main">
        <section class="wrapper style1">
		{% if user.is_authenticated and setlists %}
		<div class="inner">
		<div class="box" style="background-color:rgba(228,82,47,0.5)">
			{% for set_list in setlists %}
			<h4>{% blocktrans with set_list_date=set_list.date %}Programme de répétition de la semaine du {{ set_list_date }}: {% endblocktrans %}</h4>
			<ul class="pl-5">
				{% for morceau in set_list.morceaux.all %}
				<li><a href="{% url "partitions:listepart" morceau.nom morceau.auteur %}">{{ morceau.nom }}</a></li>
				{% endfor %}
			</ul>
			{% endfor %}
		</div>
		</div>
		{% endif %}
        <div class="inner">

        <span class="image fit">
          {% if photo %}
          <img src="{{photo.image.url}}" alt="" />  <div style="position:absolute;z-index:1;right:0;bottom:0">
          {% if photo.url %}
          <a href="{{photo.url}}" target="_blank" class="icon fa-copyright" style="color: {{photo.color}}"> {% if photo.auteur %}{{photo.auteur}}{%endif%}</a>
          {% elif photo.auteur %}
          <div class="icon fa-copyright" style="color: {{photo.color}}" > {{photo.auteur}}</div>
          {% endif %}
          </div>
          {% else %}
          <img src="{% static 'images/all_repertoire.jpg' %}" alt="" />  <div style="position:absolute;z-index:1;right:0;bottom:0">
          <div class="icon fa-copyright" style="color:#000000"> Lucas Gierzack</div></div>
          {% endif %}
        </span>
        {% if user.profile.is_chef %}
        <a href="{% url "partitions:ajouter_morceau" %}" class="button alt big">{% trans "Ajouter un morceau" %}</a> &nbsp <a href="{% url "partitions:download_musecores" %}" class="button alt big">{% trans "Télécharger tous les musecores actifs" %}</a>
        {% elif user.is_authenticated %}
         <a href="{% url "partitions:download_musecores" %}" class="button alt big">{% trans "Télécharger tous les musecores actifs" %}</a>
        {% endif %}
        <p></p>
        {% for o in some_list %}
    <tr class="{% cycle 'wrapper style1' 'wrapper style1' %}">
        ...
    </tr>
{% endfor %}
        {% for category in categories %}
        {%if not forloop.first %}

        <section class="{% cycle 'wrapper style1' 'wrapper style2' %}">
        <div class="inner">
          {% endif %}
	  <h4>{% if user.is_authenticated %}<span class="ernestocouleur">{% endif %}{% autotranslate current_language category.name category.nom_en %} :{% if user.is_authenticated %}</span>{% endif %}</h4>
          	<div class="row">
              	<div class="6u 12u$(small)">
                  <div class="table-wrapper">
    								<table class="default">
    									<thead>
    										<tr>
    											<th>{% trans "Morceau" %}</th>
    											<th>{% trans "Compositeur" %}</th>
    										</tr>
    									</thead>
                      	<tbody>
                          {% with rep=category.partitionset_set.all %}
                          {% with rep_half_length=rep|half_length %}
                            {% for partition in rep %}

                                {% if not user.is_authenticated %}
                            <tr>
                              <td>  {{ partition.nom }} </td>
                              <td> {{ partition.auteur }} </td>
                            </tr>
                              {% else %}
                              <tr>
                                <td>  <u><a href="{% url "partitions:listepart" partition.nom partition.auteur %}"
             class="fichier">{{ partition.nom }}</a> </td>
                                <td> {{ partition.auteur }}  </a></u> </td>
                                {% if user.profile.is_chef %}<td>

                                   <a href="{% url "partitions:conf_delete_morc" partition.nom partition.auteur %}"
             class="button small icon fa-trash">{% trans "Supprimer" %}</a></td>

                                {% endif %}

                              </tr>

                            {% endif %}

                            {% if forloop.counter == rep_half_length %}

                          </tbody>
                      </table>
                    </div>
                  </div>
                            <div class="6u 12u$(small)">
                              <div class="table-wrapper">
                                <table class="default">
                                  <thead>
                                    <tr>
                                      <th>{% trans "Morceau" %}</th>
                                      <th>{% trans "Compositeur" %}</th>
                                    </tr>
                                  </thead>
                                    <tbody>
                                        {% endif %}
                            {% endfor %}
                            {% endwith %}
                            {% endwith %}
                        </tbody>
                    </table>
                  </div>
                </div>

            </div>
        </div>
          </section>
        {% endfor %}

    </div>
{% endblock %}
