Fixes on systemuser backend
This commit is contained in:
parent
482de3157e
commit
2160f79ce4
|
@ -55,10 +55,6 @@ class Account(auth.AbstractBaseUser):
|
||||||
def is_staff(self):
|
def is_staff(self):
|
||||||
return self.is_superuser
|
return self.is_superuser
|
||||||
|
|
||||||
# @property
|
|
||||||
# def main_systemuser(self):
|
|
||||||
# return self.systemusers.get(is_main=True)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_main(cls):
|
def get_main(cls):
|
||||||
return cls.objects.get(pk=settings.ACCOUNTS_MAIN_PK)
|
return cls.objects.get(pk=settings.ACCOUNTS_MAIN_PK)
|
||||||
|
@ -70,8 +66,8 @@ class Account(auth.AbstractBaseUser):
|
||||||
super(Account, self).save(*args, **kwargs)
|
super(Account, self).save(*args, **kwargs)
|
||||||
if created:
|
if created:
|
||||||
self.main_systemuser = self.systemusers.create(account=self, username=self.username,
|
self.main_systemuser = self.systemusers.create(account=self, username=self.username,
|
||||||
password=self.password, is_active=active_systemuser)
|
password=self.password, is_active=active_systemuser)
|
||||||
self.save(update_fields=['main_systemuser'])
|
self.save(update_fields=('main_systemuser',))
|
||||||
elif was_active != self.is_active:
|
elif was_active != self.is_active:
|
||||||
self.notify_related()
|
self.notify_related()
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ class Operation():
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s.%s(%s)' % (self.backend, self.action, self.instance)
|
return '%s.%s(%s)' % (self.backend, self.action, self.instance)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return str(self)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
""" set() """
|
""" set() """
|
||||||
return hash(self.backend) + hash(self.instance) + hash(self.action)
|
return hash(self.backend) + hash(self.instance) + hash(self.action)
|
||||||
|
|
|
@ -74,7 +74,10 @@ class SystemUser(models.Model):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def main(self):
|
def main(self):
|
||||||
return self.account.main_systemuser
|
# On account creation main_systemuser_id is still None
|
||||||
|
if self.account.main_systemuser_id:
|
||||||
|
return self.account.main_systemuser
|
||||||
|
return type(self).objects.get(username=self.account.username)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_shell(self):
|
def has_shell(self):
|
||||||
|
|
Loading…
Reference in New Issue