1 from django.conf import settings
2 from django.db import models
3 from cas_provider.signals import cas_collect_custom_attributes
6 class Service(models.Model):
7 ordering = models.IntegerField()
8 name = models.CharField(max_length=255)
9 url = models.URLField()
10 image = models.ImageField(upload_to='accounts/service/')
13 ordering = ('ordering', )
16 class ServiceUser(models.Model):
17 service = models.ForeignKey(Service, on_delete=models.CASCADE)
18 user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
21 class ServiceGroup(models.Model):
22 service = models.ForeignKey(Service, on_delete=models.CASCADE)
23 group = models.ForeignKey('auth.Group', on_delete=models.CASCADE)
26 def user_attributes(sender, user, **kwargs):
28 'firstname': user.first_name,
29 'lastname': user.last_name,
30 'cn': ' '.join((user.first_name, user.last_name)),
33 cas_collect_custom_attributes.connect(user_attributes)