From 463dd6b3b9a2f0e76250f9109e8c1a365a6282f6 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Wed, 20 Nov 2024 16:49:09 +0100 Subject: [PATCH] Ajout d'une description aux lieux Fix #204 --- .../migrations/0112_place_description.py | 19 +++++++++++++++++++ src/agenda_culturel/models.py | 7 +++++++ .../agenda_culturel/place_detail.html | 4 ++++ .../templates/agenda_culturel/place_form.html | 2 +- src/agenda_culturel/views.py | 2 +- 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/agenda_culturel/migrations/0112_place_description.py diff --git a/src/agenda_culturel/migrations/0112_place_description.py b/src/agenda_culturel/migrations/0112_place_description.py new file mode 100644 index 0000000..eec2eed --- /dev/null +++ b/src/agenda_culturel/migrations/0112_place_description.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.9 on 2024-11-20 15:42 + +from django.db import migrations +import django_ckeditor_5.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0111_alter_referencelocation_main'), + ] + + operations = [ + migrations.AddField( + model_name='place', + name='description', + field=django_ckeditor_5.fields.CKEditor5Field(blank=True, help_text='Description of the place, including accessibility.', null=True, verbose_name='Description'), + ), + ] diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 49c1ee8..0d5626b 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -419,6 +419,13 @@ class Place(models.Model): city = models.CharField(verbose_name=_("City"), help_text=_("City name")) location = LocationField(based_fields=["name", "address", "city"], zoom=12, default=Point(3.08333, 45.783329)) + description = CKEditor5Field( + verbose_name=_("Description"), + help_text=_("Description of the place, including accessibility."), + blank=True, + null=True, + ) + aliases = ArrayField( models.CharField(max_length=512), verbose_name=_("Alternative names"), diff --git a/src/agenda_culturel/templates/agenda_culturel/place_detail.html b/src/agenda_culturel/templates/agenda_culturel/place_detail.html index 8582c54..3847610 100644 --- a/src/agenda_culturel/templates/agenda_culturel/place_detail.html +++ b/src/agenda_culturel/templates/agenda_culturel/place_detail.html @@ -49,6 +49,10 @@ {% endif %} {% endwith %} + {% if object.description %} +

Description du lieu

+ {{ object.description|safe }} + {% endif %}
diff --git a/src/agenda_culturel/templates/agenda_culturel/place_form.html b/src/agenda_culturel/templates/agenda_culturel/place_form.html index 41145da..f7bc4dc 100644 --- a/src/agenda_culturel/templates/agenda_culturel/place_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/place_form.html @@ -31,7 +31,7 @@
{% if event %} -

Description du lieu :

+

Détails de l'événement :

{% include "agenda_culturel/single-event/event-single-inc.html" with event=event noedit=1 %} {% endif %} diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 0dd4e44..3b51138 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -944,7 +944,7 @@ def event_search(request, full=False): tags = [t for t in tags if s_q == t[1]] tags.sort(key=lambda x: x[1]) tags = [t[0] for t in tags] - places = Place.objects.filter(Q(name__icontains=request.GET['q'])) + places = Place.objects.filter(Q(name__icontains=request.GET['q'])|Q(description__icontains=request.GET['q'])|Q(city__icontains=request.GET['q'])) paginator = PaginatorFilter(filter, 10, request) page = request.GET.get("page")