Ajout Agenda.statut (pour remplacer prive)
This commit is contained in:
parent
c81a8377fd
commit
af925e22fd
5 changed files with 39 additions and 5 deletions
|
|
@ -6,7 +6,7 @@ from beesgospel.models import Agenda, Chant, ChantDoc, Document, Membre, User
|
|||
|
||||
@admin.register(Agenda)
|
||||
class AgendaAdmin(admin.ModelAdmin):
|
||||
list_display = ["titre", "lieu", "date_heure", "prive"]
|
||||
list_display = ["titre", "lieu", "date_heure", "statut"]
|
||||
ordering = ["-date_heure"]
|
||||
search_fields = ["titre", "lieu"]
|
||||
date_hierarchy = "date_heure"
|
||||
|
|
|
|||
25
beesgospel/migrations/0010_agenda_statut.py
Normal file
25
beesgospel/migrations/0010_agenda_statut.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('beesgospel', '0009_remove_numero'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='agenda',
|
||||
name='statut',
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
('public', 'Événement public'), ('prive', 'Événement privé'), ('repet', 'Répétition')
|
||||
], default='', max_length=10, verbose_name='Statut',
|
||||
help_text=(
|
||||
"Un évènement privé ou une répétition ne sont visibles que pour les membres de "
|
||||
"l’association, tandis qu'un évènement public est visible de tous."
|
||||
),
|
||||
),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
|
@ -45,11 +45,20 @@ class Membre(models.Model):
|
|||
|
||||
|
||||
class Agenda(models.Model):
|
||||
class Statuts(models.TextChoices):
|
||||
PUBLIC = "public", "Événement public"
|
||||
PRIVE = "prive", "Événement privé"
|
||||
REPETITION = "repet", "Répétition"
|
||||
|
||||
titre = models.CharField("Titre", max_length=150)
|
||||
lieu = models.CharField("Lieu", max_length=80, blank=True)
|
||||
date_heure = models.DateTimeField("Date/heure")
|
||||
infos = models.TextField("Informations", blank=True)
|
||||
infos_internes = models.TextField("Informations internes", blank=True)
|
||||
statut = models.CharField("Statut", max_length=10, choices=Statuts, help_text=(
|
||||
"Un évènement privé ou une répétition ne sont visibles que pour les membres de "
|
||||
"l’association, tandis qu'un évènement public est visible de tous."
|
||||
))
|
||||
prive = models.BooleanField(
|
||||
"Privé", default=False, help_text=(
|
||||
"Un évènement privé ne peut être consulté que par les membres de "
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class HomeView(TemplateView):
|
|||
return {
|
||||
**super().get_context_data(**kwargs),
|
||||
"items": Agenda.objects.filter(
|
||||
date_heure__date__gte=date.today(), prive=False,
|
||||
date_heure__date__gte=date.today(), statut=Agenda.Statuts.PUBLIC,
|
||||
).order_by("date_heure")[:2],
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ class PresentationView(TemplateView):
|
|||
return {
|
||||
**super().get_context_data(**kwargs),
|
||||
"next_event": Agenda.objects.filter(
|
||||
date_heure__date__gte=date.today(), prive=False,
|
||||
date_heure__date__gte=date.today(), statut=Agenda.Statuts.PUBLIC,
|
||||
).order_by("date_heure").first(),
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class AgendaView(ListView):
|
|||
date_heure__gt=date.today() - timedelta(days=3),
|
||||
).order_by("date_heure")
|
||||
if not self.request.user.is_authenticated:
|
||||
qs = qs.filter(prive=False)
|
||||
qs = qs.filter(statut=Agenda.Statuts.PUBLIC)
|
||||
return qs
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<h2 class="mb-5">Agenda des prochaines prestations de la chorale</h2>
|
||||
|
||||
{% for item in object_list %}
|
||||
<div class="border-bottom border-danger mt-3{% if item.prive %} prive{% endif %}">
|
||||
<div class="border-bottom border-danger mt-3 {{ item.statut }}">
|
||||
<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">
|
||||
{{ item.date_heure|date:'D d F à H:i' }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue