Skip to content
Snippets Groups Projects
Commit 0894f86a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

hour check added for sending email

parent 54e070e9
No related branches found
No related tags found
1 merge request!47Resolve "Email to technician"
Pipeline #
...@@ -139,16 +139,20 @@ class KitRequestEmailSendJob(CronJobBase): ...@@ -139,16 +139,20 @@ class KitRequestEmailSendJob(CronJobBase):
# check if we sent email this day already # check if we sent email this day already
date = pytz.utc.localize(now.replace(hour=hour, minute=minute)) date = pytz.utc.localize(now.replace(hour=hour, minute=minute))
# TODO it's a hack assuming that we are in CEST # TODO it's a hack assuming that we are in CEST
date = date - datetime.timedelta(hours=2) date = date - datetime.timedelta(minutes=122)
jobs = CronJobLog.objects.filter(code=KitRequestEmailSendJob.code, message="mail sent", start_time__gte=date) jobs = CronJobLog.objects.filter(code=KitRequestEmailSendJob.code, message="mail sent", start_time__gte=date)
if jobs.count() == 0: if jobs.count() == 0:
if self.match_day_of_week(): date = datetime.datetime.now().replace(hour=hour, minute=minute)
data = get_kit_requests(Worker.objects.create()); if datetime.datetime.now() > date:
send_mail(data); if self.match_day_of_week():
return "mail sent" data = get_kit_requests(Worker.objects.create());
send_mail(data);
return "mail sent"
else:
return "day of week doesn't match"
else: else:
return "day of week doesn't match" return "too early"
else: else:
return "mail already sent" return "mail already sent"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment