Make message handler use local time instead of UTC
This commit is contained in:
parent
d4da464aa8
commit
430ff93e45
1 changed files with 4 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import localtime, now
|
||||||
|
|
||||||
from cronhandler.signals import cron
|
from cronhandler.signals import cron
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ def send_notifications(sender, **kwargs):
|
||||||
returns = []
|
returns = []
|
||||||
for notification in Notification.objects.all():
|
for notification in Notification.objects.all():
|
||||||
for datetime in notification.notificationdatetimeschedule_set.all():
|
for datetime in notification.notificationdatetimeschedule_set.all():
|
||||||
if not datetime.sent and datetime.datetime <= now():
|
if not datetime.sent and datetime.datetime <= localtime(now()):
|
||||||
try:
|
try:
|
||||||
returns.append(notification.send())
|
returns.append(notification.send())
|
||||||
datetime.sent = True
|
datetime.sent = True
|
||||||
|
@ -18,10 +18,10 @@ def send_notifications(sender, **kwargs):
|
||||||
except:
|
except:
|
||||||
pass # TODO: Implement some sort of error logging / admin notification
|
pass # TODO: Implement some sort of error logging / admin notification
|
||||||
for daily in notification.notificationdailyschedule_set.all():
|
for daily in notification.notificationdailyschedule_set.all():
|
||||||
if ((not daily.last_sent) or daily.last_sent < now().date()) and daily.time <= now().time():
|
if ((not daily.last_sent) or daily.last_sent < localtime(now()).date()) and daily.time <= localtime(now()).time():
|
||||||
try:
|
try:
|
||||||
returns.append(notification.send())
|
returns.append(notification.send())
|
||||||
daily.last_sent = now().date()
|
daily.last_sent = localtime(now()).date()
|
||||||
daily.save()
|
daily.save()
|
||||||
except:
|
except:
|
||||||
pass # TODO: See above
|
pass # TODO: See above
|
||||||
|
|
Loading…
Reference in a new issue