Action et affichage pour répétitions
This commit is contained in:
parent
4fad13e403
commit
1675d1e102
3 changed files with 41 additions and 3 deletions
|
|
@ -1,15 +1,38 @@
|
||||||
|
import datetime
|
||||||
|
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, Document, Membre, User
|
||||||
|
|
||||||
|
|
||||||
|
@admin.action(description="Générer répétition des 3 prochains mois")
|
||||||
|
def gen_repets(modeladmin, request, queryset):
|
||||||
|
next_wedn = datetime.date.today()
|
||||||
|
while next_wedn.isoweekday() != 3:
|
||||||
|
next_wedn += datetime.timedelta(days=1)
|
||||||
|
for i in range(12):
|
||||||
|
if not Agenda.objects.filter(
|
||||||
|
statut=Agenda.Statuts.REPETITION, date_heure__date=next_wedn
|
||||||
|
).exists():
|
||||||
|
Agenda.objects.create(
|
||||||
|
titre="Répétition", lieu="Temple Saint-Jean",
|
||||||
|
date_heure=datetime.datetime.combine(
|
||||||
|
next_wedn, datetime.time(18, 30), tzinfo=ZoneInfo("Europe/Zurich")
|
||||||
|
),
|
||||||
|
statut=Agenda.Statuts.REPETITION,
|
||||||
|
)
|
||||||
|
next_wedn += datetime.timedelta(days=7)
|
||||||
|
|
||||||
|
|
||||||
@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"]
|
||||||
ordering = ["-date_heure"]
|
ordering = ["-date_heure"]
|
||||||
search_fields = ["titre", "lieu"]
|
search_fields = ["titre", "lieu"]
|
||||||
date_hierarchy = "date_heure"
|
date_hierarchy = "date_heure"
|
||||||
|
actions = [gen_repets]
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Document)
|
@admin.register(Document)
|
||||||
|
|
|
||||||
|
|
@ -108,10 +108,25 @@ tr.editable:hover .edit-button, tr.editable:hover .delete-button { display: inli
|
||||||
.agenda_line > div { text-align: center !important; margin-top: 1em !important; }
|
.agenda_line > div { text-align: center !important; margin-top: 1em !important; }
|
||||||
}
|
}
|
||||||
.date_agenda { background-color: #ddd; text-decoration: none; }
|
.date_agenda { background-color: #ddd; text-decoration: none; }
|
||||||
|
.titre_agenda { font-size: 1.5rem; }
|
||||||
.prive {
|
.prive {
|
||||||
background-image: linear-gradient(45deg, #333333 41.67%, #6b0c0c 41.67%, #6b0c0c 50%, #333333 50%, #333333 91.67%, #6b0c0c 91.67%, #6b0c0c 100%);
|
background-image: linear-gradient(45deg, #333333 41.67%, #6b0c0c 41.67%, #6b0c0c 50%, #333333 50%, #333333 91.67%, #6b0c0c 91.67%, #6b0c0c 100%);
|
||||||
background-size: 33.94px 33.94px;
|
background-size: 33.94px 33.94px;
|
||||||
}
|
}
|
||||||
|
.repet {
|
||||||
|
background-color: #4b2f11;
|
||||||
|
}
|
||||||
|
.repet .date_agenda {
|
||||||
|
background-color: #c2a07b;
|
||||||
|
padding-top: 0 !important; padding-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
.repet .titre_agenda {
|
||||||
|
color: #c2a07b;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
.repet .lieu_agenda { color: #c2a07b; }
|
||||||
|
|
||||||
.infos_internes {
|
.infos_internes {
|
||||||
color: red;
|
color: red;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
<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 item in object_list %}
|
||||||
<div class="border-bottom border-danger mt-3 {{ item.statut }}">
|
<div class="{% if item.statut != 'repet' %}border-bottom border-danger {% endif %}mt-3 {{ item.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' }}
|
{{ item.date_heure|date:'D d F à H:i' }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-12 col-sm-8 col-lg-10 fs-4">{{ item.titre }}</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>
|
</div>
|
||||||
<div class="mt-2 mb-2">{{ item.lieu }}</div>
|
{% if item.statut != 'repet' %}<div class="mt-2 mb-2 lieu_agenda">{{ item.lieu }}</div>{% endif %}
|
||||||
{% if item.infos %}<div class="pb-3">{{ item.infos }}</div>{% endif %}
|
{% if item.infos %}<div class="pb-3">{{ item.infos }}</div>{% endif %}
|
||||||
{% if item.infos_internes and user.is_authenticated %}
|
{% if item.infos_internes and user.is_authenticated %}
|
||||||
<div class="infos_internes pb-3">{{ item.infos_internes }}</div>
|
<div class="infos_internes pb-3">{{ item.infos_internes }}</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue