kpsul/gestioncof/shared.py

33 lines
911 B
Python
Raw Normal View History

2012-06-27 23:28:35 +02:00
from django.conf import settings
from django.contrib.sites.models import Site
from django_cas_ng.backends import CASBackend
2012-07-11 17:39:20 +02:00
from gestioncof.models import CofProfile
2012-07-11 17:39:20 +02:00
2012-06-27 23:28:35 +02:00
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):
2017-05-31 22:00:51 +02:00
clipper = user.username
user.profile.login_clipper = clipper
user.profile.save()
user.email = settings.CAS_EMAIL_FORMAT % clipper
user.save()
2012-06-27 23:28:35 +02:00
return user
def context_processor(request):
2012-06-27 23:28:35 +02:00
'''Append extra data to the context of the given request'''
data = {
"user": request.user,
"site": Site.objects.get_current(),
}
2012-06-27 23:28:35 +02:00
return data