From 8c34e2f83fe9f92a1ce882f8336bd1c1ea37b78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 30 Jan 2017 13:50:24 +0100 Subject: [PATCH] proper use of messages in petits cours --- gestioncof/petits_cours_views.py | 11 ++++------- .../traitement_demande.html} | 6 ------ 2 files changed, 4 insertions(+), 13 deletions(-) rename gestioncof/templates/{traitement_demande_petit_cours.html => petits_cours/traitement_demande.html} (90%) diff --git a/gestioncof/petits_cours_views.py b/gestioncof/petits_cours_views.py index ee71d1a9..f4cafab0 100644 --- a/gestioncof/petits_cours_views.py +++ b/gestioncof/petits_cours_views.py @@ -1,9 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - from django.shortcuts import render, get_object_or_404, redirect from django.core import mail from django.core.mail import EmailMessage @@ -17,6 +13,7 @@ from django.views.decorators.csrf import csrf_exempt from django.template import loader from django.conf import settings from django.contrib.auth.decorators import login_required +from django.contrib import messages from django.db.models import Min from gestioncof.models import CofProfile @@ -29,7 +26,6 @@ from gestioncof.shared import lock_table, unlock_tables from captcha.fields import ReCaptchaField from datetime import datetime -import base64 import json @@ -139,7 +135,9 @@ def _finalize_traitement(request, demande, proposals, proposed_for, 'style="width:99%; height: 90px;">' '' }) - return render(request, "traitement_demande_petit_cours.html", + for error in errors: + messages.error(request, error) + return render(request, "petits_cours/traitement_demande.html", {"demande": demande, "unsatisfied": unsatisfied, "proposals": proposals, @@ -148,7 +146,6 @@ def _finalize_traitement(request, demande, proposals, proposed_for, "mainmail": mainmail, "attribdata": json.dumps(attribdata), "redo": redo, - "errors": errors, }) diff --git a/gestioncof/templates/traitement_demande_petit_cours.html b/gestioncof/templates/petits_cours/traitement_demande.html similarity index 90% rename from gestioncof/templates/traitement_demande_petit_cours.html rename to gestioncof/templates/petits_cours/traitement_demande.html index d51f87b5..6b43fbe6 100644 --- a/gestioncof/templates/traitement_demande_petit_cours.html +++ b/gestioncof/templates/petits_cours/traitement_demande.html @@ -4,12 +4,6 @@

Traitement de la demande de petits cours {{ demande.id }}

{% include "details_demande_petit_cours_infos.html" %}
- {% if errors %} -
- Attention: - -
- {% endif %} {% if unsatisfied %}
Attention: Impossible de trouver des propositions pour les matières suivantes: