add message

This commit is contained in:
baoliang 2020-10-11 14:58:13 +08:00
parent 0150bf4f8d
commit 8116692491
6 changed files with 10 additions and 1 deletions

View File

@ -98,6 +98,9 @@ class Task(models.Model):
def record(self):
return TaskRecord.objects.filter(task=self).count()
def records(self):
return TaskRecord.objects.filter(task=self)
def add_task_message(self, user_id):
for group in self.groups.all():
Message.objects.create(

View File

@ -16,7 +16,7 @@ def notices(request):
if request.method == 'POST':
return HttpResponse(status=405)
id = request.user.id
notices = Notice.objects.filter(user__id=id, is_read=False)
notices = Notice.objects.filter(user__id=id)
results = []
for o in notices:
result = dict()

View File

@ -88,6 +88,12 @@ def get_task(request):
result['content'] = task.content
result['total'] = task.total()
result['record'] = task.record()
# records = task.records()
# n = []
# for r in records:
# p = dict()
# profile = r.user.profile
# print(profile)
result['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S")
return JsonResponse({'status': 'success', 'message': result})