fix: 通知提醒出错

This commit is contained in:
caoqianming 2023-06-29 11:14:50 +08:00
parent 6bbbf16049
commit ef1ea0e784
1 changed files with 10 additions and 6 deletions

View File

@ -177,12 +177,16 @@ def create_remind(event: Event, params: dict):
})
elif i.post and area_level >= i.filter_area_level:
qs = User.objects.filter(posts=i.post)
if i.filter_recipient == 20: # 当事人所在部门以上
if event.employee and event.employee.user:
qs = qs.filter(depts__in=get_parent_queryset(event.employee.user.belong_dept))
elif i.filter_recipient == 40: # 属地部门以上
if event.area.belong_dept:
qs = qs.filter(depts__in=get_parent_queryset(event.area.belong_dept))
if i.filter_recipient == 20 and event.employee and event.employee.user:
qs = qs.filter(depts__in=get_parent_queryset(event.employee.user.belong_dept))
elif i.filter_recipient == 10 and event.employee and event.employee.user:
qs = qs.filter(depts=event.employee.user.belong_dept)
elif i.filter_recipient == 40 and event.area.belong_dept:
qs = qs.filter(depts__in=get_parent_queryset(event.area.belong_dept))
elif i.filter_recipient == 30 and event.area.belong_dept:
qs = qs.filter(depts=event.area.belong_dept)
else:
qs = User.objects.none()
for m in qs:
Remind.objects.get_or_create(event=event, recipient=m,
defaults={