Ajout de boutons d'accès rapide à des pages d'édition, et on interdit la suppression si l'événement n'est pas encore en status trash
- Fix #16
This commit is contained in:
parent
fbbae450ca
commit
46c1c71943
@ -591,3 +591,11 @@ nav .badge {
|
||||
border-radius: 40%;
|
||||
|
||||
}
|
||||
|
||||
form [role="button"] {
|
||||
margin: 0 0 var(--spacing) 0;
|
||||
}
|
||||
|
||||
.large {
|
||||
margin: 2em auto;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
|
||||
{% load utils_extra %}
|
||||
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
|
||||
|
||||
{% if event.status != "published" %}
|
||||
<a href="{% url 'change_status_event' event.id 'published' %}" role="button">publier {% picto_from_name "eye" %}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if event.status != "draft" %}
|
||||
<a href="{% url 'change_status_event' event.id 'draft' %}" role="button">brouillon {% picto_from_name "eye-off" %}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if event.status != "trash" %}
|
||||
<a href="{% url 'change_status_event' event.id 'trash' %}" role="button">corbeille {% picto_from_name "trash-2" %}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if event.status == "trash" %}
|
||||
<a href="{% url 'delete_event' event.id %}" role="button">supprimer définitivement {% picto_from_name "x-circle" %}</a>
|
||||
{% endif %}
|
@ -0,0 +1,43 @@
|
||||
{% extends "agenda_culturel/page.html" %}
|
||||
|
||||
{% block title %}
|
||||
{% if status == "published" %}
|
||||
Publier l'événement {{ event.title }}
|
||||
{% elif status == "draft" %}
|
||||
Déplacer l'événement {{ event.title }} dans les brouillons
|
||||
{% elif status == "trash" %}
|
||||
Mettre l'événement {{ event.title }} à la corbeille
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>
|
||||
{% if status == "published" %}
|
||||
Publier l'événement {{ event.title }}
|
||||
{% elif status == "draft" %}
|
||||
Déplacer l'événement {{ event.title }} dans les brouillons
|
||||
{% elif status == "trash" %}
|
||||
Mettre l'événement {{ event.title }} à la corbeille
|
||||
{% endif %}
|
||||
</h1>
|
||||
<article>
|
||||
<form method="post">{% csrf_token %}
|
||||
<p class="large">Êtes-vous sûr·e de vouloir
|
||||
{% if status == "published" %}
|
||||
<strong>publier</strong> l'événement « {{ event }} » du {{ event.start_day }} ?
|
||||
{% elif status == "draft" %}
|
||||
déplacer <strong>en brouillon</strong> l'événement « {{ event }} » du {{ event.start_day }} ?
|
||||
{% elif status == "trash" %}
|
||||
mettre <strong>à la corbeille</strong> l'événement « {{ event }} » du {{ event.start_day }} ?
|
||||
{% endif %}
|
||||
</p>
|
||||
{{ form }}
|
||||
<div class="grid">
|
||||
<a href="{{ cancel_url }}" role="button" class="secondary">Annuler</a>
|
||||
<input type="submit" value="Confirmer">
|
||||
</div>
|
||||
</form>
|
||||
</article>
|
||||
{% endblock %}
|
@ -20,4 +20,10 @@
|
||||
</p>
|
||||
<div class="description">
|
||||
{% if event.description_hl %}{{ event.description_hl | safe }}{% else %}{% if event.description %}{{ event.description |truncatewords:60 }}{% else %}<em>pas de description</em>{% endif %}{% endif %}
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<div class="buttons">
|
||||
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -65,8 +65,7 @@
|
||||
</div>
|
||||
{% if user.is_authenticated %}
|
||||
<div class="buttons">
|
||||
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
|
||||
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
|
||||
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %}
|
||||
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
|
||||
</svg></a>
|
||||
|
@ -58,8 +58,7 @@
|
||||
</div>
|
||||
{% if user.is_authenticated %}
|
||||
<div class="buttons">
|
||||
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
|
||||
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
|
||||
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %}
|
||||
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
|
||||
</svg></a>
|
||||
|
@ -52,8 +52,7 @@
|
||||
</div>
|
||||
{% if user.is_authenticated %}
|
||||
<div class="buttons">
|
||||
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
|
||||
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
|
||||
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</footer>
|
||||
|
@ -33,7 +33,7 @@ def picto_status(event):
|
||||
if event.is_draft():
|
||||
return picto_from_name("eye-off", "Brouillon")
|
||||
elif event.is_trash():
|
||||
return picto_from_name("trash", "À la poubelle")
|
||||
return picto_from_name("trash-2", "À la corbeille")
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
@ -20,6 +20,7 @@ urlpatterns = [
|
||||
path("events/", event_list, name='view_all_events'),
|
||||
path("event/<int:pk>-<extra>", EventDetailView.as_view(), name="view_event"),
|
||||
path("event/<int:pk>/edit", EventUpdateView.as_view(), name="edit_event"),
|
||||
path("event/<int:pk>/change-status/<status>", change_status_event, name="change_status_event"),
|
||||
path("event/<int:pk>/delete", EventDeleteView.as_view(), name="delete_event"),
|
||||
path("importer", import_from_url, name="event_import_form"),
|
||||
path("ajouter", EventCreateView.as_view(), name="add_event"),
|
||||
|
@ -235,6 +235,23 @@ class EventDetailView(UserPassesTestMixin, DetailView):
|
||||
def test_func(self):
|
||||
return self.request.user.is_authenticated or self.get_object().status != Event.STATUS.PUBLISHED
|
||||
|
||||
@login_required(login_url="/accounts/login/")
|
||||
def change_status_event(request, pk, status):
|
||||
event = get_object_or_404(Event, pk=pk)
|
||||
|
||||
if request.method == 'POST':
|
||||
event.status = Event.STATUS(status)
|
||||
event.save(update_fields=["status"])
|
||||
|
||||
if self.request.user.is_authenticated:
|
||||
return event.get_absolute_url()
|
||||
else:
|
||||
return reverse_lazy("home")
|
||||
else:
|
||||
cancel_url = request.META.get('HTTP_REFERER', '')
|
||||
if cancel_url == "":
|
||||
cancel_url = reverse_lazy("home")
|
||||
return render(request, 'agenda_culturel/event_confirm_change_status.html', {"status": status, "event": event, "cancel_url": cancel_url})
|
||||
|
||||
def import_from_url(request):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user