From e9e6f632e3ef2a79524a8540bf9b046f46633408 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 23 Nov 2018 09:44:22 +0100 Subject: [PATCH] Fix message icons and show messages on login view --- passbook/core/settings.py | 12 ++++++++++++ passbook/core/templates/login/form.html | 1 + passbook/core/templates/partials/messages.html | 10 +++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/passbook/core/settings.py b/passbook/core/settings.py index 58a58e041..e8102f3b2 100644 --- a/passbook/core/settings.py +++ b/passbook/core/settings.py @@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ import importlib import os +from django.contrib import messages + from passbook import __version__ from passbook.lib.config import CONFIG @@ -66,6 +68,16 @@ INSTALLED_APPS = [ 'passbook.tfa', ] +# Message Tag fix for bootstrap CSS Classes +MESSAGE_TAGS = { + messages.DEBUG: 'primary', + messages.INFO: 'info', + messages.SUCCESS: 'success', + messages.WARNING: 'warning', + messages.ERROR: 'danger', +} + + REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. diff --git a/passbook/core/templates/login/form.html b/passbook/core/templates/login/form.html index e7bdd9ad9..e3a224e88 100644 --- a/passbook/core/templates/login/form.html +++ b/passbook/core/templates/login/form.html @@ -7,6 +7,7 @@

{% trans 'Log In to Your Account' %}

+{% include 'partials/messages.html' %}
{% csrf_token %}
diff --git a/passbook/core/templates/partials/messages.html b/passbook/core/templates/partials/messages.html index 00ae96261..3d4f76f21 100644 --- a/passbook/core/templates/partials/messages.html +++ b/passbook/core/templates/partials/messages.html @@ -4,7 +4,15 @@ - + {% if msg.level_tag == 'danger' %} + + {% elif msg.level_tag == 'warning' %} + + {% elif msg.level_tag == 'success' %} + + {% elif msg.level_tag == 'info' %} + + {% endif %} {{ msg.message|safe }}
{% endfor %}