diff --git a/beesgospel/migrations/0012_concertitem.py b/beesgospel/migrations/0012_concertitem.py index 9270c43..1718a69 100644 --- a/beesgospel/migrations/0012_concertitem.py +++ b/beesgospel/migrations/0012_concertitem.py @@ -19,5 +19,6 @@ class Migration(migrations.Migration): ('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')), ], + options={'ordering': ['ordre']}, ), ] diff --git a/beesgospel/migrations/0013_agenda_affiche.py b/beesgospel/migrations/0013_agenda_affiche.py new file mode 100644 index 0000000..bd3ca8d --- /dev/null +++ b/beesgospel/migrations/0013_agenda_affiche.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('beesgospel', '0012_concertitem'), + ] + + operations = [ + migrations.AddField( + model_name='agenda', + name='affiche', + field=models.ImageField(blank=True, help_text='Sous forme d’image', upload_to='affiches', verbose_name='Affiche'), + ), + ] diff --git a/beesgospel/models.py b/beesgospel/models.py index ac46db8..70b7892 100644 --- a/beesgospel/models.py +++ b/beesgospel/models.py @@ -55,6 +55,9 @@ class Agenda(models.Model): date_heure = models.DateTimeField("Date/heure") infos = models.TextField("Informations", blank=True) infos_internes = models.TextField("Informations internes", blank=True) + affiche = models.ImageField( + "Affiche", blank=True, upload_to="affiches", help_text="Sous forme d’image" + ) 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." diff --git a/beesgospel/static/css/main.css b/beesgospel/static/css/main.css index fa4d4c6..e990226 100644 --- a/beesgospel/static/css/main.css +++ b/beesgospel/static/css/main.css @@ -111,6 +111,7 @@ tr.editable:hover .edit-button, tr.editable:hover .delete-button { display: inli } .date_agenda { background-color: #ddd; text-decoration: none; } .titre_agenda { font-size: 1.5rem; } +.affiche img { max-width: 100%; cursor: pointer; } .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-size: 33.94px 33.94px; diff --git a/beesgospel/static/js/main.js b/beesgospel/static/js/main.js index d81690d..7d5cab9 100644 --- a/beesgospel/static/js/main.js +++ b/beesgospel/static/js/main.js @@ -27,6 +27,11 @@ window.addEventListener('DOMContentLoaded', () => { audio.currentTime = 0; audio.src = ""; }) + attachHandlerSelector(document, ".affiche img", "click", (ev) => { + const src = ev.target.src; + document.querySelector("#modal-img").src = ev.target.src; + new bootstrap.Modal('#imagemodal').show(); + }); const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) }) diff --git a/common/urls.py b/common/urls.py index e0c08c8..f21c4ff 100644 --- a/common/urls.py +++ b/common/urls.py @@ -35,6 +35,7 @@ urlpatterns = [ path("membres/documents/", views.MediaView.as_view(prive=True), name="docs-membres"), path("media/chants/", views.MediaServeView.as_view(subdir="chants")), + path("media/affiches/", views.MediaServeView.as_view(subdir="affiches")), path( "sitemap.xml", sitemap, {"sitemaps": sitemaps}, diff --git a/templates/agenda.html b/templates/agenda.html index fbbeaa0..ab842bc 100644 --- a/templates/agenda.html +++ b/templates/agenda.html @@ -8,13 +8,26 @@ {% for even in object_list %}
-
- {{ even.date_heure|date:'D d F à H:i' }} +
+
+
+ {{ even.date_heure|date:'D d F à H:i' }} +
+
{{ even.titre }}{% if even.statut == 'repet' %} - {{ even.lieu }}{% endif %}
+
+ {% if even.statut != 'repet' %} +
{{ even.lieu }}
+ {% endif %} + {% if even.infos %} +
{{ even.infos|linebreaksbr }}
+ {% endif %}
-
{{ even.titre }}{% if even.statut == 'repet' %} - {{ even.lieu }}{% endif %}
+ {% if even.affiche %} +
+ +
+ {% endif %}
- {% if even.statut != 'repet' %}
{{ even.lieu }}
{% endif %} - {% if even.infos %}
{{ even.infos|linebreaksbr }}
{% endif %} {% if user.is_authenticated %} {% if even.infos_internes %}
{{ even.infos_internes|linebreaksbr }}
{% endif %} {% if even.programme.all %} @@ -36,4 +49,16 @@ {% endif %}
{% endfor %} + + + {% endblock %}