orverride natural key implementation for User
This commit is contained in:
parent
20200c0216
commit
863d43d18d
|
@ -0,0 +1,8 @@
|
|||
from authentic2.managers import GetByNameManager
|
||||
from authentic2.custom_user.managers import UserManager
|
||||
|
||||
class UserManager(UserManager):
|
||||
def get_by_natural_key(self, collectivity_slug, uid):
|
||||
return self.get(collectivity__slug=collectivity_slug, uid=uid)
|
||||
|
||||
|
|
@ -10,14 +10,13 @@ from django.contrib.auth.models import Group
|
|||
|
||||
from authentic2 import managers
|
||||
from authentic2.models import Service as Authentic2Service
|
||||
from authentic2.custom_user.managers import UserManager
|
||||
from authentic2.idp.signals import authorize_service
|
||||
from authentic2.custom_user.models import User as BaseUser
|
||||
from authentic2.a2_rbac.models import OrganizationalUnit
|
||||
from authentic2.constants import AUTHENTICATION_EVENTS_SESSION_KEY
|
||||
from authentic2.saml.fields import MultiSelectField
|
||||
|
||||
from . import constants
|
||||
from . import constants, managers
|
||||
|
||||
|
||||
class User(BaseUser):
|
||||
|
@ -99,11 +98,14 @@ class User(BaseUser):
|
|||
blank=True,
|
||||
null=True)
|
||||
|
||||
objects = UserManager()
|
||||
objects = managers.UserManager()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.get_full_name().strip() or self.uid
|
||||
|
||||
def natural_key(self):
|
||||
return (self.collectivity.slug, self.uid)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('agent')
|
||||
verbose_name_plural = _('agents')
|
||||
|
|
Reference in New Issue