From c1b158c72846da558bdb3c17d850ba834bf6591d Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Thu, 21 May 2020 22:03:56 +0200 Subject: [PATCH] Add support for different categories of "flash alerts" (#594) --- ihatemoney/templates/layout.html | 10 +++++++--- ihatemoney/web.py | 8 ++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ihatemoney/templates/layout.html b/ihatemoney/templates/layout.html index 89f65e72..9a145abd 100644 --- a/ihatemoney/templates/layout.html +++ b/ihatemoney/templates/layout.html @@ -119,9 +119,13 @@
- {% for message in get_flashed_messages() %} -
{{ message }}
- {% endfor %} + {% for category, message in get_flashed_messages(with_categories=true) %} + {% if category == "message" %}{# Default category for flash(msg) #} +
{{ message }}
+ {% else %} +
{{ message }}
+ {% endif %} + {% endfor %}
{% block footer %} diff --git a/ihatemoney/web.py b/ihatemoney/web.py index 4fc72a8e..45da8726 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -250,14 +250,10 @@ def create_project(): try: current_app.mail.send(msg) except SMTPRecipientsRefused: - msg_compl = 'Problem sending mail. ' - # TODO: destroy the project and cancel instead? - else: - msg_compl = '' + flash(_("Error while sending reminder email"), category="danger") # redirect the user to the next step (invite) - flash(_("%(msg_compl)sThe project identifier is %(project)s", - msg_compl=msg_compl, project=project.id)) + flash(_("The project identifier is %(project)s", project=project.id)) return redirect(url_for(".list_bills", project_id=project.id)) return render_template("create_project.html", form=form)