summaryrefslogtreecommitdiff
path: root/sublab_project/accounts/models.py
blob: 821bed354ddacdd5a1b8b34aa1e0c168f3f77c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from django.contrib.auth.models import User
from django.db import models

from django.db.models.signals import post_save
from django_auth_ldap.backend import populate_user

class UserProfile(models.Model):
    """A (dummy) user profile, needed for LDAP
    """
    user = models.OneToOneField(User)


def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)


def set_user_as_staff(sender, user, ldap_user, **kwargs):
    user.is_staff = True # Every LDAP user should be able to use admin
populate_user.connect(set_user_as_staff)