From 10159393f124585688b210003f21f1c8aa7ef3ef Mon Sep 17 00:00:00 2001 From: Maurice Debray Date: Thu, 6 Jan 2022 00:27:53 +0100 Subject: [PATCH] Set list de repet: front end random fanfaron --- partitions/admin.py | 3 ++- partitions/models.py | 8 ++++++++ partitions/templates/partitions/repertoire.html | 12 ++++++++++++ partitions/views.py | 3 ++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/partitions/admin.py b/partitions/admin.py index dc2e8bd..9cb0363 100644 --- a/partitions/admin.py +++ b/partitions/admin.py @@ -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) diff --git a/partitions/models.py b/partitions/models.py index 7470d56..2110d22 100644 --- a/partitions/models.py +++ b/partitions/models.py @@ -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")) diff --git a/partitions/templates/partitions/repertoire.html b/partitions/templates/partitions/repertoire.html index 95b4b5f..c68c4f5 100644 --- a/partitions/templates/partitions/repertoire.html +++ b/partitions/templates/partitions/repertoire.html @@ -7,6 +7,18 @@ {% block content %}
+ {% if user.is_authenticated and setlists %} +
+ {% for set_list in setlists %} +

Programme de repet de la semaine du {{ set_list.date }}

+
    + {% for morceau in set_list.morceaux.all %} +
  • {{ morceau.nom }}
  • + {% endfor %} +
+ {% endfor %} +
+ {% endif %}
diff --git a/partitions/views.py b/partitions/views.py index 5edb59b..75435c6 100644 --- a/partitions/views.py +++ b/partitions/views.py @@ -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")