Skip to content
Snippets Groups Projects
Commit 3d63c2b4 authored by root's avatar root
Browse files

timestamp workaround

parent 26abd246
No related branches found
No related tags found
1 merge request!47Resolve "Email to technician"
Pipeline #
......@@ -138,7 +138,8 @@ class KitRequestEmailSendJob(CronJobBase):
type=KIT_EMAIL_HOUR_CONFIGURATION_TYPE).value.split(":")[1])
# check if we sent email this day already
date = pytz.utc.localize(now.replace(hour=hour, minute=minute))
date = date + (datetime.datetime.utcnow() - datetime.datetime.now())
# TODO it's a hack assuming that we are in CEST
date = date - datetime.timedelta(hours=2)
jobs = CronJobLog.objects.filter(code=KitRequestEmailSendJob.code, message="mail sent", start_time__gte=date)
if jobs.count() == 0:
......@@ -147,9 +148,9 @@ class KitRequestEmailSendJob(CronJobBase):
send_mail(data);
return "mail sent"
else:
return False
return "day of week doesn't match"
else:
return False
return "mail already sent"
def match_day_of_week(self):
user_day_of_week = ConfigurationItem.objects.get(type=KIT_EMAIL_DAY_OF_WEEK_CONFIGURATION_TYPE).value
......@@ -160,6 +161,7 @@ class KitRequestEmailSendJob(CronJobBase):
try:
locale.setlocale(locale.LC_TIME, locale_name)
except:
print locale_name
traceback.print_exc(file=sys.stdout)
user_day_of_week_int = int(time.strptime(user_day_of_week, '%A').tm_wday) + 1
......
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