Modification de la vue : liste des partitions

Elles sont triées par categories
This commit is contained in:
Martin Pépin 2016-06-21 09:51:11 +02:00
parent 26aba814be
commit deee2168f9
3 changed files with 50 additions and 23 deletions
partitions
templates/partitions

View file

@ -10,8 +10,14 @@ from partitions.models import Partition, PartitionSet
from partitions.decorators import chef_required from partitions.decorators import chef_required
def liste(request): def liste(request):
partitions = PartitionSet.objects.all().order_by("nom") partitions = PartitionSet.objects.order_by("nom")
return render(request, 'partitions/liste.html', locals()) context = {
"request": request,
"active_partitions": partitions.filter(category="old").all(),
"incoming_partitions": partitions.filter(category="incoming").all(),
"old_partitions": partitions.filter(category="old").all()
}
return render(request, 'partitions/liste.html', context)
@login_required @login_required
def upload(request, nom, auteur): def upload(request, nom, auteur):

View file

@ -1,25 +1,35 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block titre %}Liste des partitions{% endblock %} {% block titre %}Liste des partitions{% endblock %}
{% block content %}<h1>Liste des partitions</h1> {% block content %}<h1>Liste des partitions</h1>
{% if suppression %} {% if suppression %}
<p>{{ suppression }}</p> <p>{{ suppression }}</p>
{% endif %} {% endif %}
{% if user.is_authenticated %}
<h3><a href="{% url "partitions.views.ajouter_morceau" %}">Ajouter un morceau</a></h3> {% if user.is_authenticated %}
{% endif %} <h3><a href="{% url "partitions.views.ajouter_morceau" %}">Ajouter un morceau</a></h3>
<ul class="filelist"> {% endif %}
{% for part in partitions %}
<li>
{% if not user.is_authenticated %} <h3>Partitions actuelles</h3>
{{ part.nom }} - {{ part.auteur }} {% for part in active_partitions %}
{% endif %} <ul class="filelist">
{% if user.is_authenticated %} {% include "partitions/liste_item.html" with part=part %}
<a href="{% url "partitions.views.listepart" part.nom part.auteur %}" class="fichier">{{ part.nom }} - {{ part.auteur }}</a> </ul>
{% endif %} {% endfor %}
{% if user.profile.is_chef %}
<a href="{% url "partitions.views.conf_delete_morc" part.nom part.auteur %}" class="supprimer">Supprimer</a> <h3>Partitions à venir</h3>
{% endif %} {% for part in incoming_partitions %}
</li> <ul class="filelist">
{% endfor %} {% include "partitions/liste_item.html" with part=part %}
</ul> </ul>
{% endfor %}
<h3>Archives</h3>
{% for part in old_partitions %}
<ul class="filelist">
{% include "partitions/liste_item.html" with part=part %}
</ul>
{% endfor %}
{% endblock %} {% endblock %}

View file

@ -0,0 +1,11 @@
<li>
{% if not user.is_authenticated %}
{{ part.nom }} - {{ part.auteur }}
{% endif %}
{% if user.is_authenticated %}
<a href="{% url "partitions.views.listepart" part.nom part.auteur %}" class="fichier">{{ part.nom }} - {{ part.auteur }}</a>
{% endif %}
{% if user.profile.is_chef %}
<a href="{% url "partitions.views.conf_delete_morc" part.nom part.auteur %}" class="supprimer">Supprimer</a>
{% endif %}
</li>