Merge branch 'setlist_repet' into 'master'

Setlist de repet

See merge request klub-dev-ens/Ernesto!17
This commit is contained in:
Lucie Galland 2022-01-09 20:46:50 +01:00
commit 9aed5d1758
14 changed files with 578 additions and 232 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 programmes de répétition" %}</a>
{% elif user.profile.is_chef_event %}
<a class="dropdown-item" href="{% url 'calendrier:create_event' %}">{% trans "Ajouter un événement" %}</a>

View file

@ -13,6 +13,7 @@
{% if user.profile.is_chef or user.is_superuser %}
<li> <a href="/admin/">{% trans "Administration" %}</a></li>
{% endif %}
{% if user.profile.is_chef %}
<li><a href="{% url 'actu:liste' %}">{% trans "Modifier les actualités" %}</a></li>
@ -24,6 +25,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 programmes de répétition" %}</a> </li>
{% endif %}
</ul>
</div>

Binary file not shown.

File diff suppressed because it is too large Load diff

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

@ -0,0 +1,44 @@
# Generated by Django 2.2.25 on 2022-01-09 18:38
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étition")),
(
"is_current",
models.CharField(
choices=[("y", "Oui"), ("n", "Non")],
default="y",
max_length=1,
verbose_name="Afficher le programme de répétition (les répétition vieilles de plus d'une semaine ne sont pas affiché d'office)",
),
),
(
"morceaux",
models.ManyToManyField(
to="partitions.PartitionSet",
verbose_name="Morceaux de la répétition (ctrl ou cmd pour en selectionner plusieurs)",
),
),
],
),
]

View file

@ -70,3 +70,39 @@ class PartitionSet(models.Model):
verbose_name = _("Morceau")
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 setlists de répétition (date et morceaux)
"""
date = models.DateField(_("Date de la répétition"))
is_current = models.CharField(
verbose_name=_(
"Afficher le programme de répétition (les répétition 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étition (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

@ -7,6 +7,20 @@
{% block content %}
<div id="main">
<section class="wrapper style1">
{% if user.is_authenticated and setlists %}
<div class="inner">
<div class="box" style="background-color:rgba(228,82,47,0.5)">
{% for set_list in setlists %}
<h4>{% blocktrans with set_list_date=set_list.date %}Programme de répétition de la semaine du {{ set_list_date }}: {% endblocktrans %}</h4>
<ul class="pl-5">
{% for morceau in set_list.morceaux.all %}
<li><a href="{% url "partitions:listepart" morceau.nom morceau.auteur %}">{{ morceau.nom }}</a></li>
{% endfor %}
</ul>
{% endfor %}
</div>
</div>
{% endif %}
<div class="inner">
<span class="image fit">

View file

@ -0,0 +1,21 @@
{% extends "gestion/base.html" %}
{% load i18n %}
{% get_current_language as current_language %}
{% load autotranslate %}
{% block titre %}{% trans "Supprimer un programme de répétition" %}{% endblock %}
{% block content %}
<div id="main">
<section class="wrapper style1">
<div class="inner">
<h4>{% blocktrans with set_list_date=setlist.date %} Supprimer le programme de répétition du {{ set_list_date }} :{% endblocktrans %}</h4>
<p>{% blocktrans with set_list=setlist %}Êtes-vous sûr.e de vouloir supprimer cette répétition : {{ set_list }}?{% endblocktrans %}</p>
<form action="" method="POST">
{% csrf_token %}
<input class="button alt" type="submit" value="{% trans "Oui" %}">
<a class="button alt" href="{% url 'partitions:list_setlist' %}">{% trans "Retour" %}</a>
</form>
</div>
</section>
</div>
{% endblock %}

View file

@ -0,0 +1,18 @@
{% extends "gestion/base.html" %}
{% load i18n %}
{%block titre %}{% trans "Ajout/modification d'un programme de répétition" %}{% 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 programmes de répétition" %}{% endblock %}
{% block content %}
<div id="main">
<section class="wrapper style1">
<div class="inner">
<h4>{% trans "Liste des programmes de répétition" %} :</h4>
<p><a href="{% url 'partitions:create_setlist' %}" class="button">{% trans "Ajouter un programme de répétition" %}</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 programme de répétition 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,15 +7,17 @@ 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
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
@ -69,11 +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="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")
@ -94,7 +106,6 @@ class Morceau(LoginRequiredMixin, TemplateView):
form = self.form_class(instance=p)
infos = mark_safe(p.infos)
infos_en = mark_safe(p.infos_en)
context["p"] = p
context["infos"] = infos
context["infos_en"] = infos_en
@ -313,3 +324,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")