Set list de repet: front end random fanfaron

This commit is contained in:
Maurice Debray 2022-01-06 00:27:53 +01:00
parent 149cc3b9f0
commit 10159393f1
4 changed files with 24 additions and 2 deletions

View file

@ -1,6 +1,7 @@
from django.contrib import admin
from .models import Category, PartitionSet
from .models import Category, PartitionSet, SetList
admin.site.register(Category)
admin.site.register(PartitionSet)
admin.site.register(SetList)

View file

@ -70,3 +70,11 @@ class PartitionSet(models.Model):
verbose_name = _("Morceau")
verbose_name_plural = _("Morceaux")
ordering = (Lower("nom"),)
class SetList(models.Model):
"""
Modèle qui stocke les metadonnées d'une setlist de répèt (date, si c'est la repet _active_)
"""
date = models.DateField(_("Date de la répèt"))
is_current = models.BooleanField(_("Afficher la répèt"), default=False)
morceaux = models.ManyToManyField("PartitionSet", verbose_name=_("Morceaux de la répèt"))

View file

@ -7,6 +7,18 @@
{% block content %}
<div id="main">
<section class="wrapper style1">
{% if user.is_authenticated and setlists %}
<div class="inner">
{% for set_list in setlists %}
<h4>Programme de repet de la semaine du {{ set_list.date }}</h4>
<ul class="pl-5">
{% for morceau in set_list.morceaux.all %}
<li>{{ morceau.nom }}</li>
{% endfor %}
</ul>
{% endfor %}
</div>
{% endif %}
<div class="inner">
<span class="image fit">

View file

@ -15,7 +15,7 @@ from django.views.generic import TemplateView
from gestion.mixins import ChefRequiredMixin
from gestion.models import Photo
from partitions.forms import UploadFileForm, UploadMorceauForm
from partitions.models import Category, Partition, PartitionSet
from partitions.models import Category, Partition, PartitionSet, SetList
from .forms import ChefEditMorceauForm
@ -74,6 +74,7 @@ class Repertoire(TemplateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["setlists"] = SetList.objects.filter(is_current=True).order_by('date').prefetch_related('morceaux')
context["categories"] = Category.objects.prefetch_related(
"partitionset_set"
).order_by("order")