Setlists de repet

This commit is contained in:
Maurice Debray 2022-01-09 01:18:50 +01:00
parent 26bd2484a2
commit 82bc6c1e1b
14 changed files with 285 additions and 5 deletions

View file

@ -3708,3 +3708,7 @@ div.spoiler
);
color: transparent;
}
select[multiple] {
height: 15em;
}

View file

@ -81,7 +81,7 @@
<a class="dropdown-item" href="{% url 'actu:liste' %}">{% trans "Modifier les actualités" %}</a>
<a class="dropdown-item" href="{% url 'liste_photo' %}">{% trans "Modifier les photos" %}</a>
<a class="dropdown-item" href="{% url 'liste_video' %}">{% trans "Modifier les vidéos" %}</a>
<a class="dropdown-item" href="{% url 'partitions:list_setlist' %}">{% trans "Gérer les setlists de répèt" %}</a>
{% elif user.profile.is_chef_event %}
<a class="dropdown-item" href="{% url 'calendrier:create_event' %}">{% trans "Ajouter un événement" %}</a>

View file

@ -12,6 +12,8 @@
<ul>
{% if user.profile.is_chef or user.is_superuser %}
<li> <a href="/admin/">{% trans "Administration" %}</a></li>
<li> <a href="{% url 'partitions:list_setlist' %}">{% trans "Gérer les setlists de répèt" %}</a> </li>
{% endif %}
{% if user.profile.is_chef %}
@ -24,6 +26,9 @@
<li><a href="{% url 'liste_photo' %}">{% trans "Modifier les photos" %}</a></li>
<li><a href="{% url 'liste_video' %}">{% trans "Modifier les vidéos" %}</a></li>
{% endif %}
{% if user.profile.is_chef %}
<li> <a href="{% url 'partitions:list_setlist' %}">{% trans "Gérer les setlists de répèt" %}</a> </li>
{% endif %}
</ul>
</div>

View file

@ -0,0 +1,41 @@
# Generated by Django 2.2.25 on 2022-01-06 16:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("partitions", "0004_auto_20210331_1350"),
]
operations = [
migrations.CreateModel(
name="SetList",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("date", models.DateField(verbose_name="Date de la répèt")),
(
"is_current",
models.BooleanField(
default=False, verbose_name="Afficher la répèt"
),
),
(
"morceaux",
models.ManyToManyField(
to="partitions.PartitionSet",
verbose_name="Morceaux de la répèt",
),
),
],
),
]

View file

@ -0,0 +1,21 @@
# Generated by Django 2.2.25 on 2022-01-08 21:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("partitions", "0005_setlist"),
]
operations = [
migrations.AlterField(
model_name="setlist",
name="morceaux",
field=models.ManyToManyField(
to="partitions.PartitionSet",
verbose_name="Morceaux de la répèt (ctrl ou cmd pour en selectionner plusieurs",
),
),
]

View file

@ -0,0 +1,21 @@
# Generated by Django 2.2.25 on 2022-01-08 22:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("partitions", "0006_auto_20220108_2158"),
]
operations = [
migrations.AlterField(
model_name="setlist",
name="morceaux",
field=models.ManyToManyField(
to="partitions.PartitionSet",
verbose_name="Morceaux de la répèt (ctrl ou cmd pour en selectionner plusieurs)",
),
),
]

View file

@ -0,0 +1,23 @@
# Generated by Django 2.2.25 on 2022-01-08 23:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("partitions", "0007_auto_20220108_2200"),
]
operations = [
migrations.AlterField(
model_name="setlist",
name="is_current",
field=models.CharField(
choices=[("y", "Oui"), ("n", "Non")],
default="y",
max_length=1,
verbose_name="Afficher la répèt (les répèt de plus d'une semaine ne sont pas affiché d'office)",
),
),
]

View file

@ -0,0 +1,23 @@
# Generated by Django 2.2.25 on 2022-01-09 00:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("partitions", "0008_auto_20220108_2350"),
]
operations = [
migrations.AlterField(
model_name="setlist",
name="is_current",
field=models.CharField(
choices=[("y", "Oui"), ("n", "Non")],
default="y",
max_length=1,
verbose_name="Afficher la répèt (les répèt vieilles de plus d'une semaine ne sont pas affiché d'office)",
),
),
]

View file

@ -71,10 +71,38 @@ class PartitionSet(models.Model):
verbose_name_plural = _("Morceaux")
ordering = (Lower("nom"),)
from datetime import date as ddate
from datetime import timedelta
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"))
is_current = models.CharField(
verbose_name=_(
"Afficher la répèt (les répèt vieilles de plus d'une semaine ne sont pas affiché d'office)"
),
max_length=1,
choices=(("y", "Oui"), ("n", "Non")),
default="y",
blank=False,
)
morceaux = models.ManyToManyField(
"PartitionSet",
verbose_name=_(
"Morceaux de la répèt (ctrl ou cmd pour en selectionner plusieurs)"
),
)
def __str__(self):
return "%s - (%s)" % (
self.date,
", ".join(self.morceaux.all().values_list("nom", flat=True)),
)
def is_visible(self):
return self.is_current == "y" and self.date > ddate.today() - timedelta(days=7)

View file

@ -0,0 +1,22 @@
{% extends "gestion/base.html" %}
{% load i18n %}
{% get_current_language as current_language %}
{% load autotranslate %}
{% block titre %}{% trans "Supprimer set-list de répèt" %}{% endblock %}
{% block content %}
<div id="main">
<section class="wrapper style1">
<div class="inner">
<h4>{% trans "Supprimer set-list de répèt" %} :</h4>
<p>Êtes-vous sûr.e de vouloir supprimer {{ setlist }}?</p>
<form action="" method="POST">
{% csrf_token %}
<input class="button" type="submit" value="Oui">
</form>
<a class="button" href="{% url 'partitions:list_setlist' %}">Retour</a>
</div>
</section>
</div>
{% endblock %}

View file

@ -0,0 +1,18 @@
{% extends "gestion/base.html" %}
{% load i18n %}
{%block titre %}{% trans "Ajout d'une actualité" %}{% endblock %}
{% block content %}
<div id="main">
<section class="wrapper style1">
<div class="inner">
<p><a href="{% url "partitions:list_setlist" %}" class="button alt">{% trans "Retour à la liste" %}</a></p>
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans "Enregistrer" %}" />
</form>
</div>
</section>
</div>
{% endblock %}

View file

@ -0,0 +1,31 @@
{% extends "gestion/base.html" %}
{% load i18n %}
{% get_current_language as current_language %}
{% load autotranslate %}
{% block titre %}{% trans "Liste des set-list de répèt" %}{% endblock %}
{% block content %}
<div id="main">
<section class="wrapper style1">
<div class="inner">
<h4>{% trans "Liste des set-list de répèt" %} :</h4>
<p><a href="{% url 'partitions:create_setlist' %}" class="button">{% trans "Ajouter une setlist" %}</a></p>
<ul class="filelist">
{% for a in setlist_list %}
<li>
<p>{% if a.is_visible %}[VISIBLE] - {% endif %}{{ a }}
<a class="button alt" href="{% url 'partitions:update_setlist' a.pk %}">{% trans "Modifier" %}</a>
<a class="button alt" href="{% url 'partitions:delete_setlist' a.pk %}">{% trans "Supprimer" %}</a></p>
</li>
{% empty %}
<p>{% trans "Pas de set list de repet pour le moment" %}</p>
{% endfor %}
</ul>
</div>
</section>
</div>
{% endblock %}

View file

@ -6,6 +6,14 @@ app_name = "partitions"
urlpatterns = [
path("", views.Repertoire.as_view(), name="liste"),
path("download", views.download_musecores, name="download_musecores"),
path("setlist/", views.SetListListView.as_view(), name="list_setlist"),
path("setlist/create", views.SetListCreate.as_view(), name="create_setlist"),
path(
"setlist/<int:pk>/update", views.SetListUpdate.as_view(), name="update_setlist"
),
path(
"setlist/<int:pk>/delete", views.SetListDelete.as_view(), name="delete_setlist"
),
path("<str:nom>/<str:auteur>/upload", views.Upload.as_view(), name="upload"),
path("<str:nom>/<str:auteur>", views.Morceau.as_view(), name="listepart"),
path("<str:nom>/<str:auteur>/see/<int:partition_id>", views.see, name="see"),

View file

@ -7,10 +7,12 @@ from django.core.files import File
from django.db.models import Q
from django.http import Http404
from django.shortcuts import HttpResponse, get_object_or_404, redirect, render
from django.urls import reverse_lazy
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from django.views.generic import (CreateView, DeleteView, ListView,
TemplateView, UpdateView)
from gestion.mixins import ChefRequiredMixin
from gestion.models import Photo
@ -69,12 +71,21 @@ def download_musecores(request):
return resp
from datetime import date, timedelta
class Repertoire(TemplateView):
template_name = "partitions/repertoire.html"
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["setlists"] = (
SetList.objects.filter(
is_current="y", date__gt=(date.today() - timedelta(days=7))
)
.order_by("date")
.prefetch_related("morceaux")
)
context["categories"] = Category.objects.prefetch_related(
"partitionset_set"
).order_by("order")
@ -314,3 +325,27 @@ def download(request, nom, auteur, partition_id):
return response
else:
return redirect("login")
class SetListListView(ChefRequiredMixin, ListView):
model = SetList
def get_queryset(self):
return SetList.objects.all().order_by("-date")
class SetListCreate(ChefRequiredMixin, CreateView):
model = SetList
fields = ["date", "morceaux", "is_current"]
success_url = reverse_lazy("partitions:list_setlist")
class SetListUpdate(ChefRequiredMixin, UpdateView):
model = SetList
fields = ["date", "morceaux", "is_current"]
success_url = reverse_lazy("partitions:list_setlist")
class SetListDelete(ChefRequiredMixin, DeleteView):
model = SetList
success_url = reverse_lazy("partitions:list_setlist")