cas_callbacks.py 457 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
from django.contrib.auth.models import User
from django.conf import settings

def create_user(tree):

    username = tree[0][0].text
    user, user_created = User.objects.get_or_create(username=username)

    if user_created:
        user.email = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN)
        user.save()
12
13
        new_student = Student.objects.create()
        new_student.user = user        
14
15

        print("Created user %s!" % username)