Skip to content

Commit

Permalink
fix: join group not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Oct 26, 2023
1 parent 1f273c5 commit 4fff58c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions saas/backend/biz/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,18 @@ def _join_group(self, subject: Subject, application: Application):

subjects = [Subject.parse_obj(one) for one in applicants]

qs = Group.objects.filter(id__in=[group["id"] for group in application.data["groups"]]).values_list(
"id", flat=True
)
group_id_set = set(qs)

# 兼容,新老数据在data都存在expired_at
default_expired_at = application.data["expired_at"]
# 加入用户组
for group in application.data["groups"]:
if group["id"] not in group_id_set:
continue

# 新数据才有,老数据则使用data外层的expired_at
expired_at = group.get("expired_at", default_expired_at)
try:
Expand Down

0 comments on commit 4fff58c

Please sign in to comment.