From fd42563f7f9a40d3f230e562076782d66208478a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 30 Jan 2017 13:46:16 +0100 Subject: [PATCH] Proper use of messages in calendar subscription --- .../{ => gestioncof}/calendar_subscription.html | 8 -------- gestioncof/views.py | 12 +++++++----- 2 files changed, 7 insertions(+), 13 deletions(-) rename gestioncof/templates/{ => gestioncof}/calendar_subscription.html (88%) diff --git a/gestioncof/templates/calendar_subscription.html b/gestioncof/templates/gestioncof/calendar_subscription.html similarity index 88% rename from gestioncof/templates/calendar_subscription.html rename to gestioncof/templates/gestioncof/calendar_subscription.html index 5f0bc988..62e154ea 100644 --- a/gestioncof/templates/calendar_subscription.html +++ b/gestioncof/templates/gestioncof/calendar_subscription.html @@ -4,14 +4,6 @@

Calendrier dynamique

-{% if success %} -

Calendrier mis à jour avec succès

-{% endif %} - -{% if error %} -

{{ error }}

-{% endif %} -

Ce formulaire vous permet de définir un calendrier dynamique compatible avec n'importe quel logiciel ou application d'agenda. Vous pouvez choisir de souscrire aux événements du COF et/ou aux spectacles BdA. diff --git a/gestioncof/views.py b/gestioncof/views.py index 3fdafd28..c67691cb 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -707,15 +707,17 @@ def calendar(request): subscription.token = uuid.uuid4() subscription.save() form.save_m2m() - return render(request, "calendar_subscription.html", + messages.success(request, + "Calendrier mis à jour avec succès.") + return render(request, "gestioncof/calendar_subscription.html", {'form': form, - 'success': True, 'token': str(subscription.token)}) else: - return render(request, "calendar_subscription.html", - {'form': form, 'error': "Formulaire incorrect"}) + messages.error(request, "Formulaire incorrect.") + return render(request, "gestioncof/calendar_subscription.html", + {'form': form}) else: - return render(request, "calendar_subscription.html", + return render(request, "gestioncof/calendar_subscription.html", {'form': CalendarForm(instance=instance), 'token': instance.token if instance else None})