From 5e4502b2bc074b290b492a62a9fd81bd541eff85 Mon Sep 17 00:00:00 2001 From: xinwen Date: Wed, 18 Aug 2021 10:19:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E8=B4=A6=E5=8F=B7=E5=88=97=E8=A1=A8=E9=87=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AF=86=E7=A0=81=E5=90=8E=E4=B8=8D=E8=83=BD=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/tasks/push_system_user.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/assets/tasks/push_system_user.py b/apps/assets/tasks/push_system_user.py index f640e03a1..3767c23e5 100644 --- a/apps/assets/tasks/push_system_user.py +++ b/apps/assets/tasks/push_system_user.py @@ -4,7 +4,7 @@ from itertools import groupby from celery import shared_task from common.db.utils import get_object_if_need, get_objects from django.utils.translation import ugettext as _ -from django.db.models import Empty +from django.db.models import Empty, Q from common.utils import encrypt_password, get_logger from assets.models import SystemUser, Asset, AuthBook @@ -238,9 +238,12 @@ def push_system_user_util(system_user, assets, task_name, username=None): no_special_auth = [] special_auth_set = set() - auth_books = AuthBook.objects.filter(username__in=usernames, asset_id__in=asset_ids) + auth_books = AuthBook.objects.filter(asset_id__in=asset_ids).filter( + Q(username__in=usernames) | Q(systemuser__username__in=usernames) + ).prefetch_related('systemuser') for auth_book in auth_books: + auth_book.load_auth() special_auth_set.add((auth_book.username, auth_book.asset_id)) for _username in usernames: