perf: 修复 org admin all

pull/7881/head
ibuler 3 years ago committed by Jiangjie.Bai
parent 3a26b9d102
commit bbdeba3659

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a8c1155ea28b70a0eb06aa39ab6ae04619cd30d02f59698fadaa6068d91a7900 oid sha256:f529bbca004aeba7532d9faf50f6f8ab5532b19bf0afd650f8360f418c03c15c
size 104348 size 104629

@ -2804,7 +2804,7 @@ msgstr "汇总"
#: ops/models/adhoc.py:339 #: ops/models/adhoc.py:339
msgid "AdHoc execution" msgid "AdHoc execution"
msgstr "任务执行历史" msgstr "任务执行"
#: ops/models/command.py:32 #: ops/models/command.py:32
msgid "Date finished" msgid "Date finished"

@ -112,7 +112,8 @@ class Organization(models.Model):
role_id = role.id role_id = role.id
with tmp_to_org(self): with tmp_to_org(self):
defaults = { defaults = {
'user': user, 'role_id': role_id, 'org_id': self.id, 'scope': 'org' 'user': user, 'role_id': role_id,
'org_id': self.id, 'scope': 'org'
} }
self.members.through.objects.update_or_create(**defaults, defaults=defaults) self.members.through.objects.update_or_create(**defaults, defaults=defaults)
@ -162,25 +163,19 @@ class Organization(models.Model):
self.delete_related_models() self.delete_related_models()
return super().delete(*args, **kwargs) return super().delete(*args, **kwargs)
@property
def admin(self):
from rbac.models import OrgRoleBinding
from users.models import User
from rbac.builtin import BuiltinRole
from .utils import tmp_to_org
# class OrgMemberManager(models.Manager): role_org_admin = BuiltinRole.org_admin.get_role()
# def remove_users(self, org, users): with tmp_to_org(self):
# from users.models import User org_admins = OrgRoleBinding.get_role_users(role_org_admin)
# pk_set = [] if not org_admins:
# for user in users: org_admins = User.objects.filter(username='admin')
# if hasattr(user, 'pk'): return org_admins
# pk_set.append(user.pk)
# else:
# pk_set.append(user)
#
# send = partial(
# signals.m2m_changed.send, sender=self.model,
# instance=org, reverse=False, model=User,
# pk_set=pk_set, using=self.db
# )
# send(action="pre_remove")
# self.filter(org_id=org.id, user_id__in=pk_set).delete()
# send(action="post_remove")
class OrganizationMember(models.Model): class OrganizationMember(models.Model):

Loading…
Cancel
Save