From bb4c8323d9bf40940fc4f2cf425100802fcd1805 Mon Sep 17 00:00:00 2001 From: Nieen <77630269+nieen@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:15:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=8E=B7=E5=8F=96=E5=AE=A1=E6=89=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/utils/workflow_audit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index c2b2b283f4..91814341c5 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -598,6 +598,8 @@ def get_review_info(self) -> ReviewInfo: ) continue group_in_db = Group.objects.get(id=g) + current_audit_users = auth_group_users([group_in_db.name], self.resource_group_id) + group_in_db.user_set.set(current_audit_users) if self.audit.current_status != WorkflowStatus.WAITING: # 总体状态不是待审核, 不设置详细的属性 review_nodes.append( From be1ad13b3f77c20d55991950c6d98057c55e987d Mon Sep 17 00:00:00 2001 From: nieen Date: Tue, 22 Oct 2024 15:52:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=E5=BD=93=E5=89=8D=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=A1=E6=89=B9=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=BC=82=E5=B8=B8=20-=20=E9=80=9A=E8=BF=87=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=BB=84=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=90=8E=E5=86=8D=E9=80=9A=E8=BF=87=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=BB=84=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/templates/workflow_display.html | 2 +- sql/utils/workflow_audit.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sql/templates/workflow_display.html b/sql/templates/workflow_display.html index d5a7188357..af5bfe54f9 100644 --- a/sql/templates/workflow_display.html +++ b/sql/templates/workflow_display.html @@ -8,7 +8,7 @@ {{ n.group.name }}( - {% for u in n.group.user_set.all %} + {% for u in n.filtered_user_set %} {{ u.username }} {% endfor %}) diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index 91814341c5..aa457ead6a 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -44,6 +44,7 @@ class ReviewNodeType(Enum): @dataclass class ReviewNode: group: Optional[Group] = None + filtered_user_set: Optional[Users] = None node_type: ReviewNodeType = ReviewNodeType.GROUP is_current_node: bool = False is_passed_node: bool = False @@ -597,14 +598,19 @@ def get_review_info(self) -> ReviewInfo: ) ) continue + # 获取指定权限组名称 group_in_db = Group.objects.get(id=g) + # 获取资源组内关联指定权限组的用户 current_audit_users = auth_group_users([group_in_db.name], self.resource_group_id) - group_in_db.user_set.set(current_audit_users) + current_audit_user_ids = current_audit_users.values_list('id', flat=True) + # 过滤Group对象的user_set,只保留当前审核用户 + group_filtered_user_set = group_in_db.user_set.filter(id__in=current_audit_user_ids) if self.audit.current_status != WorkflowStatus.WAITING: # 总体状态不是待审核, 不设置详细的属性 review_nodes.append( ReviewNode( group=group_in_db, + filtered_user_set=group_filtered_user_set, ) ) continue @@ -614,6 +620,7 @@ def get_review_info(self) -> ReviewInfo: review_nodes.append( ReviewNode( group=group_in_db, + filtered_user_set=group_filtered_user_set, is_current_node=True, is_passed_node=False, ) @@ -624,6 +631,7 @@ def get_review_info(self) -> ReviewInfo: review_nodes.append( ReviewNode( group=group_in_db, + filtered_user_set=group_filtered_user_set, is_passed_node=False, ) ) @@ -632,6 +640,7 @@ def get_review_info(self) -> ReviewInfo: review_nodes.append( ReviewNode( group=group_in_db, + filtered_user_set=group_filtered_user_set, is_passed_node=True, ) ) From 73f714cad730f135703bdb0b5a549d35150b8fbf Mon Sep 17 00:00:00 2001 From: nieen Date: Tue, 22 Oct 2024 18:55:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:black=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/utils/workflow_audit.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql/utils/workflow_audit.py b/sql/utils/workflow_audit.py index aa457ead6a..43e0e8252c 100644 --- a/sql/utils/workflow_audit.py +++ b/sql/utils/workflow_audit.py @@ -601,10 +601,14 @@ def get_review_info(self) -> ReviewInfo: # 获取指定权限组名称 group_in_db = Group.objects.get(id=g) # 获取资源组内关联指定权限组的用户 - current_audit_users = auth_group_users([group_in_db.name], self.resource_group_id) - current_audit_user_ids = current_audit_users.values_list('id', flat=True) + current_audit_users = auth_group_users( + [group_in_db.name], self.resource_group_id + ) + current_audit_user_ids = current_audit_users.values_list("id", flat=True) # 过滤Group对象的user_set,只保留当前审核用户 - group_filtered_user_set = group_in_db.user_set.filter(id__in=current_audit_user_ids) + group_filtered_user_set = group_in_db.user_set.filter( + id__in=current_audit_user_ids + ) if self.audit.current_status != WorkflowStatus.WAITING: # 总体状态不是待审核, 不设置详细的属性 review_nodes.append(