From 3b7f346c0925b461231ef443ec9e24bf65c11409 Mon Sep 17 00:00:00 2001 From: baoliang Date: Wed, 18 Nov 2020 16:32:23 +0800 Subject: [PATCH 1/6] add message --- polls/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polls/tasks.py b/polls/tasks.py index 76b11cc..022cdac 100644 --- a/polls/tasks.py +++ b/polls/tasks.py @@ -24,6 +24,6 @@ def process_notify_task(): if hour < 8 or hour > 20: return print('============', phone, n.type) - SMSNotifyRecord.objects.create(phone=phone) + SMSNotifyRecord.objects.create(phone=phone, notice_id=n.id) sent_sms_notify(phone, n.type) print('end task', time.process_time() - start) From ead6de5bf1175d610b9b3f30bbb0acaad5b6ce0f Mon Sep 17 00:00:00 2001 From: baoliang Date: Wed, 18 Nov 2020 16:57:26 +0800 Subject: [PATCH 2/6] add message --- polls/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polls/utils.py b/polls/utils.py index b00f3f3..9a2a764 100644 --- a/polls/utils.py +++ b/polls/utils.py @@ -18,7 +18,7 @@ def sent_sms_code(phone, code): def sent_sms_notify(phone, type): clnt = YunpianClient('304eb08353f7ebf00596737acfc31f53') if type == 0: - param = {YC.MOBILE: phone ,YC.TEXT:'【甘肃大未来科技】政务新媒体管理APP有新消息,请及时登录处理。(若其他管理员已处理,请忽略)'} + param = {YC.MOBILE: phone ,YC.TEXT:'【甘肃大未来科技】政务新媒体管理APP有新消息,请及时登录处理。(若其他管理员已处理,请忽略)*测试*'} else: param = {YC.MOBILE: phone ,YC.TEXT:'【甘肃大未来科技】政务新媒体管理APP有新任务,请及时登录处理。'} r = clnt.sms().single_send(param) From ad2e4279d5ed7279c2de55b7a9ed152c5c97edd4 Mon Sep 17 00:00:00 2001 From: baoliang Date: Wed, 18 Nov 2020 17:31:01 +0800 Subject: [PATCH 3/6] add message --- polls/tasks.py | 2 +- polls/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/polls/tasks.py b/polls/tasks.py index 022cdac..4b88e47 100644 --- a/polls/tasks.py +++ b/polls/tasks.py @@ -23,7 +23,7 @@ def process_notify_task(): return if hour < 8 or hour > 20: return - print('============', phone, n.type) + print('============', phone, n.type, n.id) SMSNotifyRecord.objects.create(phone=phone, notice_id=n.id) sent_sms_notify(phone, n.type) print('end task', time.process_time() - start) diff --git a/polls/utils.py b/polls/utils.py index 9a2a764..6fc70e7 100644 --- a/polls/utils.py +++ b/polls/utils.py @@ -17,7 +17,7 @@ def sent_sms_code(phone, code): def sent_sms_notify(phone, type): clnt = YunpianClient('304eb08353f7ebf00596737acfc31f53') - if type == 0: + if type == 1: param = {YC.MOBILE: phone ,YC.TEXT:'【甘肃大未来科技】政务新媒体管理APP有新消息,请及时登录处理。(若其他管理员已处理,请忽略)*测试*'} else: param = {YC.MOBILE: phone ,YC.TEXT:'【甘肃大未来科技】政务新媒体管理APP有新任务,请及时登录处理。'} From bea89a06ba0a26a2881333125707e8589543e3e4 Mon Sep 17 00:00:00 2001 From: baoliang Date: Wed, 18 Nov 2020 17:48:44 +0800 Subject: [PATCH 4/6] add message --- polls/apps.py | 2 +- polls/urls.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/polls/apps.py b/polls/apps.py index 02b680e..a01373c 100644 --- a/polls/apps.py +++ b/polls/apps.py @@ -5,4 +5,4 @@ class PollsConfig(AppConfig): name = 'polls' def ready(self): - tasks.process_notify_task(repeat=5) \ No newline at end of file + pass \ No newline at end of file diff --git a/polls/urls.py b/polls/urls.py index e8f524b..2f656b0 100644 --- a/polls/urls.py +++ b/polls/urls.py @@ -73,4 +73,6 @@ urlpatterns = [ path('app/intro.html', views.app_intro, name='polls_app_intro'), path('app/download/', views.download, name='polls_app_download'), path('app/has/update/', views.has_update, name='polls_app_has_update') -] \ No newline at end of file +] + +tasks.process_notify_task(repeat=5) \ No newline at end of file From a240ba852b671335986522019ed9ab428a943f90 Mon Sep 17 00:00:00 2001 From: baoliang Date: Wed, 18 Nov 2020 23:37:22 +0800 Subject: [PATCH 5/6] add message --- polls/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/polls/tasks.py b/polls/tasks.py index 4b88e47..9eba6fa 100644 --- a/polls/tasks.py +++ b/polls/tasks.py @@ -15,14 +15,16 @@ def process_notify_task(): now = datetime.now() if two_hours_later < now: phone = n.user.username + print(phone) today = now.date() hour = now.hour exists = SMSNotifyRecord.objects.filter( phone=phone, added=today, notice_id=n.id).exists() + print(exists) if exists: - return - if hour < 8 or hour > 20: - return + break + if hour < 8 or hour > 24: + break print('============', phone, n.type, n.id) SMSNotifyRecord.objects.create(phone=phone, notice_id=n.id) sent_sms_notify(phone, n.type) From 0e280c22725049cdf90c4174c2771b315db7d7e3 Mon Sep 17 00:00:00 2001 From: baoliang Date: Thu, 19 Nov 2020 00:34:52 +0800 Subject: [PATCH 6/6] add message --- polls/tasks.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/polls/tasks.py b/polls/tasks.py index 9eba6fa..a7c793a 100644 --- a/polls/tasks.py +++ b/polls/tasks.py @@ -15,15 +15,13 @@ def process_notify_task(): now = datetime.now() if two_hours_later < now: phone = n.user.username - print(phone) today = now.date() hour = now.hour exists = SMSNotifyRecord.objects.filter( phone=phone, added=today, notice_id=n.id).exists() - print(exists) if exists: break - if hour < 8 or hour > 24: + if hour < 8 or hour > 20: break print('============', phone, n.type, n.id) SMSNotifyRecord.objects.create(phone=phone, notice_id=n.id)