Skip to content

Commit

Permalink
fix:当前节点获取审批用户列表异常
Browse files Browse the repository at this point in the history
- 通过权限组获取用户列表后再通过当前资源组筛选
  • Loading branch information
nieen committed Oct 22, 2024
1 parent bb4c832 commit be1ad13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sql/templates/workflow_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- 当前节点 -->
<u class="text-danger">
{{ n.group.name }}(
{% for u in n.group.user_set.all %}
{% for u in n.filtered_user_set %}
<span class="text-primary">{{ u.username }}</span>
{% endfor %})
</u>
Expand Down
11 changes: 10 additions & 1 deletion sql/utils/workflow_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
)
Expand All @@ -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,
)
)
Expand All @@ -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,
)
)
Expand Down

0 comments on commit be1ad13

Please sign in to comment.