Ajout de l'édition des événements
This commit is contained in:
parent
1f44889db8
commit
b94e391792
@ -148,3 +148,16 @@ footer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.infos-and-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: stretch
|
||||
}
|
||||
|
||||
.infos-and-buttons .infos {
|
||||
flex: 50;
|
||||
}
|
||||
|
||||
.infos-and-buttons .buttons {
|
||||
flex: auto;
|
||||
}
|
@ -3,6 +3,12 @@
|
||||
{% load utils_extra %}
|
||||
{% load event_extra %}
|
||||
|
||||
{% comment %}
|
||||
TODO:
|
||||
* utiliser flex plutôt que float pour l'image et pour la date
|
||||
* gérer le flex des boutons dans le cas de petits écrans
|
||||
{% endcomment %}
|
||||
|
||||
<article>
|
||||
{% if display in "in list by day" %}
|
||||
{% if display == "in list by day" and event|can_show_start_time %}
|
||||
@ -76,39 +82,44 @@
|
||||
{% comment %}
|
||||
On affiche le pied qui contient les informations de tags, catégories, etc
|
||||
{% endcomment %}
|
||||
<footer>
|
||||
<p>
|
||||
{% if mode %}
|
||||
{% if category %}
|
||||
{{ event.category | small_cat }}
|
||||
<footer class="infos-and-buttons">
|
||||
<div class="infos">
|
||||
<p>
|
||||
{% if mode %}
|
||||
{% if category %}
|
||||
{{ event.category | small_cat }}
|
||||
{% else %}
|
||||
{% url 'view_mode_cat' selected_mode.name event.category.pk as url_cat %}
|
||||
{{ event.category | small_cat:url_cat }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% url 'view_mode_cat' selected_mode.name event.category.pk as url_cat %}
|
||||
{{ event.category | small_cat:url_cat }}
|
||||
{{ event.category | small_cat }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ event.category | small_cat }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
{% for tag in event.tags %}
|
||||
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
|
||||
</p>
|
||||
<p>
|
||||
{% for tag in event.tags %}
|
||||
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
|
||||
{% endfor %}
|
||||
</p>
|
||||
|
||||
{% if event.reference_urls %}
|
||||
{% if display in "in list by day" %}
|
||||
<p>Source{{ event.reference_urls|pluralize }} :
|
||||
{% else %}
|
||||
<p>Cet événement est proposé par :
|
||||
{% endif %}
|
||||
{% for eurl in event.reference_urls %}
|
||||
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
|
||||
{% if event.reference_urls %}
|
||||
{% if display in "in list by day" %}
|
||||
<p>Source{{ event.reference_urls|pluralize }} :
|
||||
</p>
|
||||
{% else %}
|
||||
<p>Cet événement est proposé par :
|
||||
{% endif %}
|
||||
{% for eurl in event.reference_urls %}
|
||||
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% else %}
|
||||
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
|
||||
{% endif %}
|
||||
|
||||
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
{% extends "agenda_culturel/page.html" %}
|
||||
|
||||
{% block title %}Supprimer {{ object.title }}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Suppression de l'événement {{ object.title }} ({{ object.start_day }})</h1>
|
||||
<form method="post">{% csrf_token %}
|
||||
<p>Êtes-vous sûr·e de vouloir supprimer l'événement « {{ object }} » ?</p>
|
||||
{{ form }}
|
||||
<input type="submit" value="Confirmer">
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
@ -0,0 +1,13 @@
|
||||
{% extends "agenda_culturel/page.html" %}
|
||||
|
||||
{% block title %}Proposer un événement{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<h1>Proposer un événement</h1>
|
||||
|
||||
<form method="post">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Enregistrer">
|
||||
</form>
|
||||
{% endblock %}
|
@ -0,0 +1,15 @@
|
||||
{% extends "agenda_culturel/page.html" %}
|
||||
|
||||
{% block title %}Éditer {{ object.title }}{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% block content %}
|
||||
<h1>Édition de l'événement {{ object.title }} ({{ object.start_day }})</h1>
|
||||
|
||||
<form method="post">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Enregistrer">
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
@ -2,6 +2,11 @@
|
||||
|
||||
{% block title %}Tous les événements{% endblock %}
|
||||
|
||||
{% comment %}
|
||||
TODO:
|
||||
* améliorer le rendu ici
|
||||
{% endcomment %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Derniers événements soumis</h1>
|
||||
|
@ -41,6 +41,7 @@
|
||||
<summary aria-haspopup="listbox" role="link">Événements</summary>
|
||||
<ul role="listbox">
|
||||
<li><a href="{% url 'event_import_form' %}">Importer</a></li>
|
||||
<li><a href="{% url 'add_event' %}">Créer</a></li>
|
||||
<li><a>Exporter</a></li>
|
||||
{% if user.is_authenticated %}
|
||||
<li><a href="{% url 'view_all_events' %}">Gérer</a></li>
|
||||
|
@ -17,7 +17,10 @@ urlpatterns = [
|
||||
path("tags/", tag_list, name='view_all_tags'),
|
||||
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>/delete", EventDeleteView.as_view(), name="delete_event"),
|
||||
path("importer", EventSubmissionFormView.as_view(), name="event_import_form"),
|
||||
path("ajouter", EventCreateView.as_view(), name="add_event"),
|
||||
path("admin/", admin.site.urls),
|
||||
path('accounts/', include('django.contrib.auth.urls')),
|
||||
path("test_app/", include("test_app.urls")),
|
||||
|
@ -1,5 +1,7 @@
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.views.generic import ListView, DetailView, FormView
|
||||
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
|
||||
from .forms import EventSubmissionModelForm
|
||||
from .celery import create_event_from_submission
|
||||
@ -10,6 +12,7 @@ from enum import StrEnum
|
||||
from datetime import datetime, timedelta
|
||||
from django.db.models import Q
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import activate, get_language_info
|
||||
import django_filters
|
||||
@ -100,6 +103,22 @@ def tag_list(request):
|
||||
return render(request, 'agenda_culturel/tags.html', context)
|
||||
|
||||
|
||||
class EventCreateView(CreateView):
|
||||
model = Event
|
||||
fields = ["title"] # TODO add elements
|
||||
template_name_suffix = "_create_form"
|
||||
|
||||
|
||||
class EventUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = Event
|
||||
fields = ["title"] # TODO add elements
|
||||
|
||||
|
||||
class EventDeleteView(LoginRequiredMixin, DeleteView):
|
||||
model = Event
|
||||
success_url = reverse_lazy('view_all_events')
|
||||
|
||||
|
||||
class EventDetailView(DetailView):
|
||||
model = Event
|
||||
template_name = "agenda_culturel/page-event.html"
|
||||
|
Loading…
Reference in New Issue
Block a user