Modification de la vue : liste des partitions
Elles sont triées par categories
This commit is contained in:
parent
26aba814be
commit
deee2168f9
3 changed files with 50 additions and 23 deletions
|
@ -10,8 +10,14 @@ from partitions.models import Partition, PartitionSet
|
|||
from partitions.decorators import chef_required
|
||||
|
||||
def liste(request):
|
||||
partitions = PartitionSet.objects.all().order_by("nom")
|
||||
return render(request, 'partitions/liste.html', locals())
|
||||
partitions = PartitionSet.objects.order_by("nom")
|
||||
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
|
||||
def upload(request, nom, auteur):
|
||||
|
|
|
@ -1,25 +1,35 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block titre %}Liste des partitions{% endblock %}
|
||||
|
||||
{% block content %}<h1>Liste des partitions</h1>
|
||||
{% if suppression %}
|
||||
<p>{{ suppression }}</p>
|
||||
{% endif %}
|
||||
{% if user.is_authenticated %}
|
||||
<h3><a href="{% url "partitions.views.ajouter_morceau" %}">Ajouter un morceau</a></h3>
|
||||
{% endif %}
|
||||
<ul class="filelist">
|
||||
{% for part in partitions %}
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if suppression %}
|
||||
<p>{{ suppression }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<h3><a href="{% url "partitions.views.ajouter_morceau" %}">Ajouter un morceau</a></h3>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h3>Partitions actuelles</h3>
|
||||
{% for part in active_partitions %}
|
||||
<ul class="filelist">
|
||||
{% include "partitions/liste_item.html" with part=part %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
|
||||
<h3>Partitions à venir</h3>
|
||||
{% for part in incoming_partitions %}
|
||||
<ul class="filelist">
|
||||
{% include "partitions/liste_item.html" with part=part %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
|
||||
<h3>Archives</h3>
|
||||
{% for part in old_partitions %}
|
||||
<ul class="filelist">
|
||||
{% include "partitions/liste_item.html" with part=part %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
|
11
templates/partitions/liste_item.html
Normal file
11
templates/partitions/liste_item.html
Normal 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>
|
Loading…
Reference in a new issue