Ajout de l'édition des événements
This commit is contained in:
parent
1f44889db8
commit
b94e391792
@ -148,3 +148,16 @@ footer {
|
|||||||
clear: both;
|
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 utils_extra %}
|
||||||
{% load event_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>
|
<article>
|
||||||
{% if display in "in list by day" %}
|
{% if display in "in list by day" %}
|
||||||
{% if display == "in list by day" and event|can_show_start_time %}
|
{% if display == "in list by day" and event|can_show_start_time %}
|
||||||
@ -76,39 +82,44 @@
|
|||||||
{% comment %}
|
{% comment %}
|
||||||
On affiche le pied qui contient les informations de tags, catégories, etc
|
On affiche le pied qui contient les informations de tags, catégories, etc
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
<footer>
|
<footer class="infos-and-buttons">
|
||||||
<p>
|
<div class="infos">
|
||||||
{% if mode %}
|
<p>
|
||||||
{% if category %}
|
{% if mode %}
|
||||||
{{ event.category | small_cat }}
|
{% 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 %}
|
{% else %}
|
||||||
{% url 'view_mode_cat' selected_mode.name event.category.pk as url_cat %}
|
{{ event.category | small_cat }}
|
||||||
{{ event.category | small_cat:url_cat }}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
</p>
|
||||||
{{ event.category | small_cat }}
|
<p>
|
||||||
{% endif %}
|
{% for tag in event.tags %}
|
||||||
</p>
|
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
|
||||||
<p>
|
{% endfor %}
|
||||||
{% for tag in event.tags %}
|
</p>
|
||||||
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
|
|
||||||
|
{% 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 %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% if event.reference_urls %}
|
|
||||||
{% if display in "in list by day" %}
|
|
||||||
<p>Source{{ event.reference_urls|pluralize }} :
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Cet événement est proposé par :
|
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for eurl in event.reference_urls %}
|
</div>
|
||||||
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
|
<div class="buttons">
|
||||||
{% endfor %}
|
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
|
||||||
</p>
|
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
|
||||||
{% else %}
|
</div>
|
||||||
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</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 %}
|
{% block title %}Tous les événements{% endblock %}
|
||||||
|
|
||||||
|
{% comment %}
|
||||||
|
TODO:
|
||||||
|
* améliorer le rendu ici
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>Derniers événements soumis</h1>
|
<h1>Derniers événements soumis</h1>
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<summary aria-haspopup="listbox" role="link">Événements</summary>
|
<summary aria-haspopup="listbox" role="link">Événements</summary>
|
||||||
<ul role="listbox">
|
<ul role="listbox">
|
||||||
<li><a href="{% url 'event_import_form' %}">Importer</a></li>
|
<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>
|
<li><a>Exporter</a></li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li><a href="{% url 'view_all_events' %}">Gérer</a></li>
|
<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("tags/", tag_list, name='view_all_tags'),
|
||||||
path("events/", event_list, name='view_all_events'),
|
path("events/", event_list, name='view_all_events'),
|
||||||
path("event/<int:pk>-<extra>", EventDetailView.as_view(), name="view_event"),
|
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("importer", EventSubmissionFormView.as_view(), name="event_import_form"),
|
||||||
|
path("ajouter", EventCreateView.as_view(), name="add_event"),
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
path("test_app/", include("test_app.urls")),
|
path("test_app/", include("test_app.urls")),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.views.generic import ListView, DetailView, FormView
|
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 .forms import EventSubmissionModelForm
|
||||||
from .celery import create_event_from_submission
|
from .celery import create_event_from_submission
|
||||||
@ -10,6 +12,7 @@ from enum import StrEnum
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from django.db.models import Q
|
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 gettext_lazy as _
|
||||||
from django.utils.translation import activate, get_language_info
|
from django.utils.translation import activate, get_language_info
|
||||||
import django_filters
|
import django_filters
|
||||||
@ -100,6 +103,22 @@ def tag_list(request):
|
|||||||
return render(request, 'agenda_culturel/tags.html', context)
|
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):
|
class EventDetailView(DetailView):
|
||||||
model = Event
|
model = Event
|
||||||
template_name = "agenda_culturel/page-event.html"
|
template_name = "agenda_culturel/page-event.html"
|
||||||
|
Loading…
Reference in New Issue
Block a user