From 8116692491a35013bed8cd0ded2d72b5ec75abcd Mon Sep 17 00:00:00 2001 From: baoliang Date: Sun, 11 Oct 2020 14:58:13 +0800 Subject: [PATCH] add message --- polls/models.py | 3 +++ .../views/__pycache__/message.cpython-38.pyc | Bin 2820 -> 2820 bytes polls/views/__pycache__/notice.cpython-38.pyc | Bin 4204 -> 4204 bytes polls/views/__pycache__/task.cpython-38.pyc | Bin 3268 -> 3268 bytes polls/views/notice.py | 2 +- polls/views/task.py | 6 ++++++ 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/polls/models.py b/polls/models.py index 28d9b71..c8d426f 100644 --- a/polls/models.py +++ b/polls/models.py @@ -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( diff --git a/polls/views/__pycache__/message.cpython-38.pyc b/polls/views/__pycache__/message.cpython-38.pyc index f4475cf0f0bc092f9722806d0acc261a9cca8153..18b03703d086539adbbf5eaf04ce5aeddeebabe8 100644 GIT binary patch delta 96 zcmZn>YZ2oP<>lpK00RHTO&ht_urWqW-oX~dXt!CIou84>ezG!$52MrM0*+-swm4_H pkTX!JCR>p)kSbCI5%!ZOaQZX4Pkz98lG_d>-~=MvCvV{j0019p79{`x delta 96 zcmZn>YZ2oP<>lpK0D}1KjT^bwurc16yn`)@(SEZqJ3k|%!(?R+A4ccN1suzOY;n$X pAs3)hO|~LqAXTIaA{-`9;PhwonEZhAB)2_Cz!^k%Oy0s3002>!7SaF! diff --git a/polls/views/__pycache__/notice.cpython-38.pyc b/polls/views/__pycache__/notice.cpython-38.pyc index cf5365b8b98504cc77a8200eed9a6548f3edf3b1..f7346d5f97ee139367ea6fe26da49f31002b8288 100644 GIT binary patch delta 601 zcmZXQJ8KkC6vyY>J2N}8^T=egFJoM03zZ>TNF%2;YaYC*@%JM;(vdabMF5F^7yYG2jBKVpT$0UZU_7xdA=~MiCF?;aDWp2IZ^oBhrpn_{o zW0ITg@{m8a)1UA6kM=(vz1jHwYBQ>yvOXE$t5bylnYg9H#WUGtJ s0Ur33bjw|Z^8e9hIC6(%UX^ju9}mtf=b!gnftNjWG*2AU1OFZT1v@~1t^fc4 delta 573 zcmaE(@J4|*l$V!_0SMYR*Ttu8Pf zW^n;ooM0CB0-hAEg^WNxH;~V~fVYNqAtNJ0p-Bl}3QrAl3hx}I6qdr ziey1-W)L9mdq~7X!(&mlmV|Rir>{5k<0v1*C=pM1Uz z%%cemA6p(BA#m7n0`+Th7O8?P5}bUHPki$vo@Pcdgx4%UGQL0}q)2?SHlLILM&Q8A Ub`%0f1lUA2sEL~o@~vhB0F-rkegFUf diff --git a/polls/views/__pycache__/task.cpython-38.pyc b/polls/views/__pycache__/task.cpython-38.pyc index fee30e686de025561c0f23eb35a447b58e1cb16e..977792f6c2dfe50737fba2ea3b5f050454c42682 100644 GIT binary patch delta 41 vcmX>ic|?*gl$V!_0SJDsX^MB|+sLQH#mK(dkc*9xF?F*AcPAsW3=<;&)@BI_ delta 41 vcmX>ic|?*gl$V!_0SGeQHpZ{x-N>iJ#mKnXkc*9xF@CcJcPAsW7!xA^)`$rZ diff --git a/polls/views/notice.py b/polls/views/notice.py index 64f9b90..4749b35 100644 --- a/polls/views/notice.py +++ b/polls/views/notice.py @@ -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() diff --git a/polls/views/task.py b/polls/views/task.py index 80a889c..4f7b0de 100644 --- a/polls/views/task.py +++ b/polls/views/task.py @@ -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})