Ajout modèle ConcertItem
This commit is contained in:
parent
1675d1e102
commit
f24f88087a
7 changed files with 78 additions and 11 deletions
|
|
@ -4,7 +4,9 @@ from zoneinfo import ZoneInfo
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
|
|
||||||
from beesgospel.models import Agenda, Chant, ChantDoc, Document, Membre, User
|
from beesgospel.models import (
|
||||||
|
Agenda, Chant, ChantDoc, ConcertItem, Document, Membre, User
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@admin.action(description="Générer répétition des 3 prochains mois")
|
@admin.action(description="Générer répétition des 3 prochains mois")
|
||||||
|
|
@ -26,6 +28,11 @@ def gen_repets(modeladmin, request, queryset):
|
||||||
next_wedn += datetime.timedelta(days=7)
|
next_wedn += datetime.timedelta(days=7)
|
||||||
|
|
||||||
|
|
||||||
|
class ConcertItemInline(admin.TabularInline):
|
||||||
|
model = ConcertItem
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Agenda)
|
@admin.register(Agenda)
|
||||||
class AgendaAdmin(admin.ModelAdmin):
|
class AgendaAdmin(admin.ModelAdmin):
|
||||||
list_display = ["titre", "lieu", "date_heure", "statut"]
|
list_display = ["titre", "lieu", "date_heure", "statut"]
|
||||||
|
|
@ -33,6 +40,7 @@ class AgendaAdmin(admin.ModelAdmin):
|
||||||
search_fields = ["titre", "lieu"]
|
search_fields = ["titre", "lieu"]
|
||||||
date_hierarchy = "date_heure"
|
date_hierarchy = "date_heure"
|
||||||
actions = [gen_repets]
|
actions = [gen_repets]
|
||||||
|
inlines = [ConcertItemInline]
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Document)
|
@admin.register(Document)
|
||||||
|
|
|
||||||
23
beesgospel/migrations/0012_concertitem.py
Normal file
23
beesgospel/migrations/0012_concertitem.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('beesgospel', '0011_remove_agenda_prive'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ConcertItem',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('item', models.CharField(blank=True, max_length=250)),
|
||||||
|
('ordre', models.SmallIntegerField(default=0)),
|
||||||
|
('remarque', models.TextField(blank=True, verbose_name='Remarque')),
|
||||||
|
('chant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='beesgospel.chant')),
|
||||||
|
('concert', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='programme', to='beesgospel.agenda')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -129,3 +129,19 @@ class ChantDoc(models.Model):
|
||||||
@property
|
@property
|
||||||
def fichier_son(self):
|
def fichier_son(self):
|
||||||
return self.fichier and self.fichier.name.endswith((".m4a", ".mp3", ".wav"))
|
return self.fichier and self.fichier.name.endswith((".m4a", ".mp3", ".wav"))
|
||||||
|
|
||||||
|
|
||||||
|
class ConcertItem(models.Model):
|
||||||
|
concert = models.ForeignKey(Agenda, on_delete=models.CASCADE, related_name="programme")
|
||||||
|
chant = models.ForeignKey(Chant, on_delete=models.CASCADE, blank=True, null=True)
|
||||||
|
item = models.CharField(max_length=250, blank=True)
|
||||||
|
ordre = models.SmallIntegerField(default=0)
|
||||||
|
remarque = models.TextField("Remarque", blank=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["ordre"]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
if self.chant:
|
||||||
|
return f"Chant {self.chant} pour le concert {self.concert}"
|
||||||
|
return f"{self.item} pour le concert {self.concert}"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
src: url("../fonts/harlow-solid-regular.ttf");
|
src: url("../fonts/harlow-solid-regular.ttf");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html { scroll-padding-top: 8rem; }
|
||||||
|
|
||||||
body {
|
body {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background: #333;
|
background: #333;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,9 @@ class AgendaView(ListView):
|
||||||
qs = Agenda.objects.filter(
|
qs = Agenda.objects.filter(
|
||||||
date_heure__gt=date.today() - timedelta(days=3),
|
date_heure__gt=date.today() - timedelta(days=3),
|
||||||
).order_by("date_heure")
|
).order_by("date_heure")
|
||||||
if not self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
|
qs = qs.prefetch_related("programme")
|
||||||
|
else:
|
||||||
qs = qs.filter(statut=Agenda.Statuts.PUBLIC)
|
qs = qs.filter(statut=Agenda.Statuts.PUBLIC)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,34 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2 class="mb-5">Agenda des prochaines prestations de la chorale</h2>
|
<h2 class="mb-5">Agenda des prochaines prestations de la chorale</h2>
|
||||||
|
|
||||||
{% for item in object_list %}
|
{% for even in object_list %}
|
||||||
<div class="{% if item.statut != 'repet' %}border-bottom border-danger {% endif %}mt-3 {{ item.statut }}">
|
<div class="{% if even.statut != 'repet' %}border-bottom border-danger {% endif %}mt-3 {{ even.statut }}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-12 col-sm-4 col-lg-2 text-black rounded align-self-center text-center fw-bold pt-2 pb-2 date_agenda">
|
<div class="col col-12 col-sm-4 col-lg-2 text-black rounded align-self-center text-center fw-bold pt-2 pb-2 date_agenda">
|
||||||
{{ item.date_heure|date:'D d F à H:i' }}
|
{{ even.date_heure|date:'D d F à H:i' }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-12 col-sm-8 col-lg-10 titre_agenda">{{ item.titre }}{% if item.statut == 'repet' %} - {{ item.lieu }}{% endif %}</div>
|
<div class="col col-12 col-sm-8 col-lg-10 titre_agenda">{{ even.titre }}{% if even.statut == 'repet' %} - {{ even.lieu }}{% endif %}</div>
|
||||||
</div>
|
</div>
|
||||||
{% if item.statut != 'repet' %}<div class="mt-2 mb-2 lieu_agenda">{{ item.lieu }}</div>{% endif %}
|
{% if even.statut != 'repet' %}<div class="mt-2 mb-2 lieu_agenda">{{ even.lieu }}</div>{% endif %}
|
||||||
{% if item.infos %}<div class="pb-3">{{ item.infos }}</div>{% endif %}
|
{% if even.infos %}<div class="pb-3">{{ even.infos }}</div>{% endif %}
|
||||||
{% if item.infos_internes and user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<div class="infos_internes pb-3">{{ item.infos_internes }}</div>
|
{% if even.infos_internes %}<div class="infos_internes pb-3">{{ even.infos_internes }}</div>{% endif %}
|
||||||
|
{% if even.programme.all %}
|
||||||
|
<div class="d-flex">
|
||||||
|
<div class="ms-auto programme">
|
||||||
|
<button class="btn btn-outline-warning mb-2" type="button" data-bs-toggle="collapse" data-bs-target="#prog{{ even.pk }}" aria-expanded="false" aria-controls="prog{{ even.pk }}">Programme</button> <i><small>pour membres uniquement</small></i>
|
||||||
|
<div id="prog{{ even.pk }}" class="collapse">
|
||||||
|
<ol>
|
||||||
|
{% for item in even.programme.all %}
|
||||||
|
<li>{% if item.chant %}<a href="{% url 'liste-chants' %}#chant{{ item.chant.pk }}">{{ item.chant }}</a>{% else %}{{ item.item }}{% endif %}
|
||||||
|
{% if item.remarque %} <span><i><small>({{ item.remarque }})</small></i></span>{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<tr><th scope="col">Titre</th><th></th><th></th>
|
<tr><th scope="col">Titre</th><th></th><th></th>
|
||||||
{% if perms.beesgospel.change_chant %}<th scope="col" class="boutons"></th>{% endif %}</tr>
|
{% if perms.beesgospel.change_chant %}<th scope="col" class="boutons"></th>{% endif %}</tr>
|
||||||
{% for chant in object_list %}
|
{% for chant in object_list %}
|
||||||
<tr class="editable">
|
<tr class="editable" id="chant{{ chant.pk }}">
|
||||||
<td class="titre_chant">{{ chant.titre }}</td>
|
<td class="titre_chant">{{ chant.titre }}</td>
|
||||||
<td>{% for doc in chant.chantdoc_set.all %}
|
<td>{% for doc in chant.chantdoc_set.all %}
|
||||||
{% if doc.fichier_son %}
|
{% if doc.fichier_son %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue