fix task create bug

This commit is contained in:
baoliang 2021-03-12 14:15:52 +08:00
parent 27d5548f6f
commit 557f745849
3 changed files with 4 additions and 5 deletions

View File

@ -99,8 +99,8 @@ class Task(models.Model):
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)
def add_groups(self, groups): def add_groups(self, groups):
if not len(groups): # if not len(groups):
groups = Group.objects.filter(status='开启') # groups = Group.objects.filter(status='开启')
for g in groups: for g in groups:
self.groups.add(g) self.groups.add(g)

View File

@ -69,12 +69,11 @@ def create_task(request):
for group in groups: for group in groups:
users = Group_user.objects.filter(group_id=group) users = Group_user.objects.filter(group_id=group)
for u in users: for u in users:
g = Group.objects.get(id=group)
profile = Userprofile.objects.filter(user_id=u.user_id).first() profile = Userprofile.objects.filter(user_id=u.user_id).first()
if profile and profile.status == 1: if profile and profile.status == 1:
content = '%s在群组“%s”发布了任务,请查收消息' % (creater_profile, g.name) content = '%s在群组“%s”发布了任务,请查收消息' % (creater_profile, u.group.name)
Notice.create_normal_notice(u.user_id, content, group) Notice.create_normal_notice(u.user_id, content, group)
phones = [u.username for u in users] phones = [u.user.username for u in users]
send_tnps(phones, '任务', content) send_tnps(phones, '任务', content)
return JsonResponse({'status': 'success'}) return JsonResponse({'status': 'success'})