gestioCOF/kfet/signals.py

20 lines
690 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
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') and
hasattr(request, 'GET') and
'k-fet' in request.GET.get('next', '')):
messages.info(
request,
('<a href="{}" target="_blank">Connexion en utilisateur partagé ?</a>'
.format(reverse('kfet.login.genericteam'))),
extra_tags='safe')