Fix message icons and show messages on login view

This commit is contained in:
Jens Langhammer 2018-11-23 09:44:22 +01:00
parent 095a5c0268
commit e9e6f632e3
3 changed files with 22 additions and 1 deletions

View File

@ -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.

View File

@ -7,6 +7,7 @@
<header class="login-pf-header">
<h1>{% trans 'Log In to Your Account' %}</h1>
</header>
{% include 'partials/messages.html' %}
<form method="POST">
{% csrf_token %}
<div class="form-group">

View File

@ -4,7 +4,15 @@
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span class="pficon pficon-close"></span>
</button>
<span class="pficon pficon-{{ msg.level_tag }}"></span>
{% if msg.level_tag == 'danger' %}
<span class="pficon pficon-error-circle-o"></span>
{% elif msg.level_tag == 'warning' %}
<span class="pficon pficon-warning-triangle-o"></span>
{% elif msg.level_tag == 'success' %}
<span class="pficon pficon-ok"></span>
{% elif msg.level_tag == 'info' %}
<span class="pficon pficon-info"></span>
{% endif %}
<strong>{{ msg.message|safe }}</strong>
</div>
{% endfor %}