mirror of https://github.com/jumpserver/jumpserver
commit
cc30a20b7c
|
@ -77,7 +77,7 @@ class Connectivity:
|
|||
return cls(cls.UNKNOWN, timezone.now())
|
||||
|
||||
@classmethod
|
||||
def set(cls, key, value, ttl=0):
|
||||
def set(cls, key, value, ttl=None):
|
||||
cache.set(key, value, ttl)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -72,7 +72,8 @@ class Organization(models.Model):
|
|||
org = cls.default() if default else None
|
||||
return org
|
||||
|
||||
@lazyproperty
|
||||
# @lazyproperty
|
||||
# lazyproperty 导致用户列表中角色显示出现不稳定的情况, 如果不加会导致数据库操作次数太多
|
||||
def org_users(self):
|
||||
from users.models import User
|
||||
if self.is_real():
|
||||
|
@ -83,9 +84,9 @@ class Organization(models.Model):
|
|||
return users
|
||||
|
||||
def get_org_users(self):
|
||||
return self.org_users
|
||||
return self.org_users()
|
||||
|
||||
@lazyproperty
|
||||
# @lazyproperty
|
||||
def org_admins(self):
|
||||
from users.models import User
|
||||
if self.is_real():
|
||||
|
@ -93,7 +94,7 @@ class Organization(models.Model):
|
|||
return User.objects.filter(role=User.ROLE_ADMIN)
|
||||
|
||||
def get_org_admins(self):
|
||||
return self.org_admins
|
||||
return self.org_admins()
|
||||
|
||||
def org_id(self):
|
||||
if self.is_real():
|
||||
|
@ -103,7 +104,7 @@ class Organization(models.Model):
|
|||
else:
|
||||
return ''
|
||||
|
||||
@lazyproperty
|
||||
# @lazyproperty
|
||||
def org_auditors(self):
|
||||
from users.models import User
|
||||
if self.is_real():
|
||||
|
@ -111,7 +112,7 @@ class Organization(models.Model):
|
|||
return User.objects.filter(role=User.ROLE_AUDITOR)
|
||||
|
||||
def get_org_auditors(self):
|
||||
return self.org_auditors
|
||||
return self.org_auditors()
|
||||
|
||||
def get_org_members(self, exclude=()):
|
||||
from users.models import User
|
||||
|
|
|
@ -49,12 +49,7 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet):
|
|||
if isinstance(users, User):
|
||||
users = [users]
|
||||
if current_org and current_org.is_real():
|
||||
# current_org.users.add(*users)
|
||||
# 如果在真实组织下创建用户,使用上面的语句会出现用户角色显示不稳定的问题
|
||||
# 可能是current_org的users add操作是进程不安全的
|
||||
# User Model 中的 remove 操作没有出现问题,暂时不做更改
|
||||
for user in users:
|
||||
user.related_user_orgs.add(current_org.id)
|
||||
current_org.users.add(*users)
|
||||
self.send_created_signal(users)
|
||||
|
||||
def get_permissions(self):
|
||||
|
|
Loading…
Reference in New Issue