gestioCOF/gestioncof/shared.py
2018-10-06 13:15:33 +02:00

25 lines
844 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.conf import settings
from django.contrib.sites.models import Site
from django_cas_ng.backends import CASBackend
class COFCASBackend(CASBackend):
def clean_username(self, username):
# Le CAS de l'ENS accepte les logins avec des espaces au début
# et à la fin, ainsi quavec une casse variable. On normalise pour
# éviter les doublons.
return username.strip().lower()
def configure_user(self, user):
clipper = user.username
user.profile.login_clipper = clipper
user.profile.save()
user.email = settings.CAS_EMAIL_FORMAT % clipper
user.save()
return user
def context_processor(request):
"""Append extra data to the context of the given request"""
data = {"user": request.user, "site": Site.objects.get_current()}
return data