On peut modifier le lieu d'un événement

Fix #407
This commit is contained in:
Jean-Marie Favreau 2025-04-26 14:09:40 +02:00
parent a3b20bc3f6
commit 0d4d6b5e9b
9 changed files with 31 additions and 11 deletions

View File

@ -885,6 +885,9 @@ class EventAddPlaceForm(Form):
).format(self.instance.location)
else:
self.fields.pop("add_alias")
if self.instance.exact_location:
self.fields["place"].initial = self.instance.exact_location
self.fields["add_alias"].initial = False
def modified_event(self):
return self.cleaned_data.get("place")

View File

@ -1,7 +1,14 @@
{% extends "agenda_culturel/page.html" %}
{% load static %}
{% block title %}
{% block og_title %}Ajouter un lieu à {{ object.title }}{% endblock %}
{% block og_title %}
{% if object.exact_location %}
Modifier le lieu de
{% else %}
Ajouter un lieu à
{% endif %}
{{ object.title }}
{% endblock %}
{% endblock %}
{% load cat_extra %}
{% block entete_header %}
@ -26,7 +33,14 @@
{% load static_content_extra %}
<article>
<header>
<h1>Ajouter un lieu à {{ object.title }} ({{ object.start_day }})</h1>
<h1>
{% if object.exact_location %}
Modifier le lieu de
{% else %}
Ajouter un lieu à
{% endif %}
{{ object.title }} ({{ object.start_day }})
</h1>
</header>
<p>
Si le lieu est disponible dans la liste déroulante, sélectionne-le. S'il n'est pas disponible, utilise

View File

@ -168,7 +168,7 @@
{{ event.exact_location.name }}, {{ event.exact_location.city }}
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
<a href="{% url 'set_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
{% else %}
{{ event.location }}
{% endif %}

View File

@ -40,7 +40,7 @@
<a href="{{ event.exact_location.get_absolute_url }}">{{ event.exact_location.name }}, {{ event.exact_location.city }}</a>
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
<a href="{% url 'set_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
{% else %}
{{ event.location }}
{% endif %}

View File

@ -50,7 +50,7 @@
<a href="{{ event.exact_location.get_absolute_url }}">{{ event.exact_location.name }}, {{ event.exact_location.city }}</a>
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
<a href="{% url 'set_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
{% else %}
{{ event.location }}
{% endif %}

View File

@ -5,7 +5,7 @@
<header>
<div class="slide-buttons">
<div class="buttons">
<a href="{% url 'add_place_to_event' event.pk %}" role="button">Ajouter le lieu {% picto_from_name "map-pin" %}</a>
<a href="{% url 'set_place_to_event' event.pk %}" role="button">Ajouter le lieu {% picto_from_name "map-pin" %}</a>
</div>
</div>
<h3>
@ -20,7 +20,7 @@
<a href="{{ event.exact_location.get_absolute_url }}">{{ event.exact_location.name }}, {{ event.exact_location.city }}</a>
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
<a href="{% url 'set_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
{% else %}
{{ event.location }}
{% endif %}

View File

@ -87,12 +87,15 @@
<p>
{% picto_from_name "map-pin" %}
<a href="{{ event.exact_location.get_absolute_url }}">{{ event.exact_location.name }}, {{ event.exact_location.city }}</a>
{% if user.is_authenticated %}
(<a href="{% url 'set_place_to_event' event.pk %}">modifier</a>)
{% endif %}
</p>
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<p>
{% picto_from_name "map-pin" %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">
<a href="{% url 'set_place_to_event' event.pk %}" class="missing-data">
{% if event.location %}
{{ event.location }}
{% else %}

View File

@ -473,9 +473,9 @@ urlpatterns = [
path("places/", PlaceListView.as_view(), name="view_places"),
path("place/<int:pk>/edit", PlaceUpdateView.as_view(), name="edit_place"),
path(
"event/<int:pk>/addplace",
"event/<int:pk>/setplace",
UnknownPlaceAddView.as_view(),
name="add_place_to_event",
name="set_place_to_event",
),
path(
"events/unknown-places",

View File

@ -181,7 +181,7 @@ class UnknownPlaceAddView(PermissionRequiredMixin, SuccessMessageMixin, UpdateVi
"agenda_culturel.change_event",
)
form_class = EventAddPlaceForm
template_name = "agenda_culturel/place_unknown_form.html"
template_name = "agenda_culturel/event_set_place_form.html"
def form_valid(self, form):
self.modified_event = form.cleaned_data.get("place")