Proper use of messages in survies

This commit is contained in:
Martin Pépin 2017-01-29 16:24:07 +01:00
parent d31b9f59ab
commit 0666b5288f
2 changed files with 16 additions and 15 deletions

View file

@ -5,13 +5,6 @@
{% block realcontent %}
<h2>Sondage: {{ survey.title }}</h2>
{% if success %}
{% if deleted %}
<p class="success">Votre réponse a bien été supprimée !</p>
{% else %}
<p class="success">Votre réponse a bien été enregistrée ! Vous pouvez cependant la modifier jusqu'à la fin du sondage.</p>
{% endif %}
{% endif %}
{% if survey.details %}
<p>{{ survey.details }}</p>
{% endif %}

View file

@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import unicodecsv
import uuid
from datetime import timedelta
@ -16,6 +12,7 @@ from django.contrib.auth.views import login as django_login_view
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.utils import timezone
from django.contrib import messages
import django.utils.six as six
from gestioncof.models import Survey, SurveyAnswer, SurveyQuestion, \
@ -153,10 +150,21 @@ def survey(request, survey_id):
except SurveyAnswer.DoesNotExist:
current_answer = None
form = SurveyForm(survey=survey)
return render(request, "survey.html", {"survey": survey, "form": form,
"success": success,
"deleted": deleted,
"current_answer": current_answer})
# Messages
if success:
if deleted:
messages.success(request,
"Votre réponse a bien été supprimée")
else:
messages.success(request,
"Votre réponse a bien été enregistrée ! Vous "
"pouvez cependant la modifier jusqu'à la fin "
"du sondage.")
return render(request, "gestioncof/survey.html", {
"survey": survey,
"form": form,
"current_answer": current_answer
})
def get_event_form_choices(event, form):