Ajout message pour proposer connexion standard

This commit is contained in:
Aurélien Delobelle 2016-09-10 22:49:07 +02:00
parent f614051365
commit fe7f84ffad
5 changed files with 79 additions and 5 deletions

View file

@ -0,0 +1 @@
default_app_config = 'kfet.apps.KFetConfig'

14
kfet/apps.py Normal file
View file

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from builtins import *
from django.apps import AppConfig
class KFetConfig(AppConfig):
name = 'kfet'
verbose_name = "Application K-Fêt"
def ready(self):
import kfet.signals

16
kfet/signals.py Normal file
View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from builtins import *
from django.contrib import messages
from django.contrib.auth.signals import user_logged_in
from django.core.urlresolvers import reverse
from django.dispatch import receiver
@receiver(user_logged_in)
def messages_on_login(sender, request, user, **kwargs):
if (not user.username == 'kfet_genericteam'
and user.has_perm('kfet.is_team')):
messages.info(request, '<a href="%s">Connexion en utilisateur partagé ?</a>' % reverse('kfet.login.genericteam'), extra_tags='safe')

View file

@ -263,3 +263,37 @@ textarea {
display:block; display:block;
padding:5px 20px; padding:5px 20px;
} }
/*
* Messages
*/
.messages .alert {
padding:10px 15px;
margin:0;
border:0;
border-radius:0;
}
.messages .alert-dismissible {
padding-right:35px;
}
.messages .alert .close {
top:0;
right:0;
}
.messages .alert-info {
color:inherit;
background-color:#ccc;
}
.messages .alert-error {
color:inherit;
background-color:rgba(200,16,46,0.2);
}
.messages .alert-success {
color:#333;
}

View file

@ -1,7 +1,16 @@
{% if messages %} {% if messages %}
<ul class="messages"> <div class="row messages">
{% for message in messages %} {% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> <div class="col-sm-12 item">
{% endfor %} <div class="alert alert-{{ message.level_tag }} alert-dismissible fade in{% if message.tags %} {{ message.tags }}{% endif %}">
</ul> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>
{% if 'safe' in message.tags %}
{{ message|safe }}
{% else %}
{{ message }}
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endif %} {% endif %}