Skip to content

Commit

Permalink
Add support for different categories of "flash alerts" (spiral-projec…
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste Jonglez committed May 21, 2020
1 parent 428ada4 commit 046c575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 7 additions & 3 deletions ihatemoney/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ <h6 class="dropdown-header">{{ _('Languages') }}</h6>
</div>

<div class="messages">
{% for message in get_flashed_messages() %}
<div class="flash alert alert-success">{{ message }}</div>
{% endfor %}
{% for category, message in get_flashed_messages(with_categories=true) %}
{% if category == "message" %}{# Default category for flash(msg) #}
<div class="flash alert alert-success">{{ message }}</div>
{% else %}
<div class="flash alert alert-{{ category }}">{{ message }}</div>
{% endif %}
{% endfor %}
</div>

{% block footer %}
Expand Down
8 changes: 2 additions & 6 deletions ihatemoney/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 046c575

Please sign in to comment.