From 2432b9a55331bb82355524dcd3bb2a80a97728d5 Mon Sep 17 00:00:00 2001 From: xinwen Date: Mon, 12 Oct 2020 19:29:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(orgs):=20=E7=BB=84=E7=BB=87=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=88=90=E5=91=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/orgs/models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/orgs/models.py b/apps/orgs/models.py index 0b732506b..b244ddec4 100644 --- a/apps/orgs/models.py +++ b/apps/orgs/models.py @@ -231,7 +231,7 @@ def _none2list(*args): def _users2pks(users, admins, auditors): - return [user.pk for user in chain(users, admins, auditors)] + return [user.pk for user in chain(users, admins, auditors) if hasattr(user, 'pk')] class UserRoleMapper(dict): @@ -295,11 +295,11 @@ class OrgMemeberManager(models.Manager): ) oms_add = [] - for users, role in add_mapper: - for user in users: - if isinstance(user, models.Model): - user = user.id - oms_add.append(self.model(org_id=org.id, user_id=user, role=role)) + for _users, _role in add_mapper: + for _user in _users: + if isinstance(_user, models.Model): + _user = _user.id + oms_add.append(self.model(org_id=org.id, user_id=_user, role=_role)) send = partial(signals.m2m_changed.send, sender=self.model, instance=org, reverse=False, model=User, pk_set=_users2pks(users, admins, auditors), using=self.db)