From d36dbe17a0793f8f0e7d73fd81c03591eb1fc87c Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 6 Jul 2024 15:23:21 +0200 Subject: [PATCH] Ajout d'une carte de tous les lieux --- src/agenda_culturel/models.py | 3 + .../templates/agenda_culturel/page.html | 3 + .../agenda_culturel/place_detail.html | 18 ++-- .../templates/agenda_culturel/place_list.html | 90 ++++++++++--------- .../agenda_culturel/place_list_admin.html | 64 +++++++++++++ .../templates/agenda_culturel/side-nav.html | 4 +- src/agenda_culturel/urls.py | 1 + src/agenda_culturel/views.py | 10 ++- 8 files changed, 142 insertions(+), 51 deletions(-) create mode 100644 src/agenda_culturel/templates/agenda_culturel/place_list_admin.html diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index ae9261c..90b0637 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -250,6 +250,9 @@ class Place(models.Model): def nb_events(self): return Event.objects.filter(exact_location=self).count() + def nb_events_future(self): + return Event.objects.filter(start_day__gte=datetime.now()).filter(exact_location=self).count() + def match(self, event): if self.aliases: return event.location in self.aliases diff --git a/src/agenda_culturel/templates/agenda_culturel/page.html b/src/agenda_culturel/templates/agenda_culturel/page.html index 424059a..d944911 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page.html +++ b/src/agenda_culturel/templates/agenda_culturel/page.html @@ -85,6 +85,9 @@
Mentions légales
+
+ Lieux +
À propos
diff --git a/src/agenda_culturel/templates/agenda_culturel/place_detail.html b/src/agenda_culturel/templates/agenda_culturel/place_detail.html index c3bb3d2..ec63b89 100644 --- a/src/agenda_culturel/templates/agenda_culturel/place_detail.html +++ b/src/agenda_culturel/templates/agenda_culturel/place_detail.html @@ -23,7 +23,7 @@
{% if perms.agenda_culturel.change_place %} - < Tous les lieux + < Tous les lieux {% endif %} {% if perms.agenda_culturel.change_place %}
@@ -38,11 +38,14 @@
  • Adresse : {{ object.address }}, {{ object.city }}
  • Coordonnée GPS : {{ object.location }}
  • - {% if object.nb_events > 0 %} -
  • Nombre d'événements : {{ object.nb_events }}
  • - {% else %} -
  • Aucun événement n'est enregistré dans ce lieu
  • - {% endif %} + + {% with place.nb_events_future as nb %} + {% if nb > 0 %} +
  • {{ nb }} événement{{ nb|pluralize }} à venir
  • + {% else %} +
  • Aucun événement à venir
  • + {% endif %} + {% endwith %}
@@ -56,10 +59,11 @@ }).addTo(map); var marker = L.marker([{{ object.location }}]).addTo(map); +

Voir aussi les autres lieux

{% if object_list %} -

Événements

+

Événements du lieu

{% include "agenda_culturel/navigation.html" with page_obj=page_obj %} diff --git a/src/agenda_culturel/templates/agenda_culturel/place_list.html b/src/agenda_culturel/templates/agenda_culturel/place_list.html index bcb4e9c..7f03f71 100644 --- a/src/agenda_culturel/templates/agenda_culturel/place_list.html +++ b/src/agenda_culturel/templates/agenda_culturel/place_list.html @@ -1,63 +1,71 @@ {% extends "agenda_culturel/page.html" %} -{% block title %}Questions de modération{% endblock %} +{% block title %}Lieux{% endblock %} {% load utils_extra %} +{% load static %} {% load cat_extra %} {% block entete_header %} {% css_categories %} + + + + {% endblock %} +{% block fluid %}{% endblock %} + {% block content %} -
+
{% include "agenda_culturel/static_content.html" with name="places" url_path="/places" %}
+ + +
-

Lieux

+

Les lieux

- {% include "agenda_culturel/navigation.html" with page_obj=page_obj %} +
+
- {% if object_list %} - {% for place in object_list %} -
-
- -

{{ place.name }}

+ +
+ {% if object_list %} + {% for place in object_list %} +

{{ place.name }}

    -
  • Adresse : {{ place.address }}, {{ place.city }}
  • +
  • Adresse : {% if place.address %}{{ place.address }}, {% endif %}{{ place.city }}
  • Coordonnée GPS : {{ place.location }}
  • + {% with place.nb_events_future as nb %} + {% if nb > 0 %} +
  • {{ nb }} événement{{ nb|pluralize }} à venir
  • + {% endif %} + {% endwith %}
- {% if place.aliases|length > 0 %} -

Alias : {% for alias in place.aliases %}{{ alias }}{% if not forloop.last %}, {% endif %}{% endfor %}

- {% else %} -

Ce lieu n'a pas d'alias défini

- {% endif %} - {% if place.nb_events > 0 %} -

Nombre d'événements : {{ place.nb_events }}

- {% else %} -

Aucun événement n'est enregistré dans ce lieu

- {% endif %} -
- -
- {% endfor %} - {% else %} -

Il n'y a aucun lieu défini.

- {% endif %} -
- {% include "agenda_culturel/navigation.html" with page_obj=page_obj %} -
- + {% endfor %} + {% else %} +

Il n'y a aucun lieu défini.

+ {% endif %} +
+
- -{% include "agenda_culturel/side-nav.html" with current="places" %} - + {% endblock %} \ No newline at end of file diff --git a/src/agenda_culturel/templates/agenda_culturel/place_list_admin.html b/src/agenda_culturel/templates/agenda_culturel/place_list_admin.html new file mode 100644 index 0000000..98dee32 --- /dev/null +++ b/src/agenda_culturel/templates/agenda_culturel/place_list_admin.html @@ -0,0 +1,64 @@ +{% extends "agenda_culturel/page.html" %} + +{% block title %}Administration des lieux{% endblock %} + +{% load utils_extra %} +{% load cat_extra %} +{% block entete_header %} + {% css_categories %} +{% endblock %} + +{% block content %} +
+
+
+ +

Lieux

+
+ {% include "agenda_culturel/navigation.html" with page_obj=page_obj %} + + {% if object_list %} + {% for place in object_list %} +
+
+ +

{{ place.name }}

+
    +
  • Adresse : {{ place.address }}, {{ place.city }}
  • +
  • Coordonnée GPS : {{ place.location }}
  • +
+ {% if place.aliases|length > 0 %} +

Alias : {% for alias in place.aliases %}{{ alias }}{% if not forloop.last %}, {% endif %}{% endfor %}

+ {% else %} +

Ce lieu n'a pas d'alias défini

+ {% endif %} + {% if place.nb_events > 0 %} +

Nombre d'événements : {{ place.nb_events }}

+ {% else %} +

Aucun événement n'est enregistré dans ce lieu

+ {% endif %} +
+ +
+ {% endfor %} + {% else %} +

Il n'y a aucun lieu défini.

+ {% endif %} +
+ {% include "agenda_culturel/navigation.html" with page_obj=page_obj %} +
+ +
+ +{% include "agenda_culturel/side-nav.html" with current="places" %} +
+ +{% endblock %} \ No newline at end of file diff --git a/src/agenda_culturel/templates/agenda_culturel/side-nav.html b/src/agenda_culturel/templates/agenda_culturel/side-nav.html index f9a0260..61c34fb 100644 --- a/src/agenda_culturel/templates/agenda_culturel/side-nav.html +++ b/src/agenda_culturel/templates/agenda_culturel/side-nav.html @@ -18,17 +18,19 @@
  • Consulter les étiquettes
  • + {% if perms.agenda_culturel.change_place %}

    Lieux

    + {% endif %} {% if perms.agenda_culturel.view_batchimportation or perms.agenda_culturel.view_recurrentimport or perms.agenda_culturel.view_categorisationrule%}

    Traitements automatiques