Ensures bulletin sends correctly if running across midnight

This commit is contained in:
Yingtong Li 2020-01-04 17:14:34 +11:00
parent 96e45c0c5c
commit e49d2d963a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -33,6 +33,8 @@ import logging
import time import time
import urllib.parse import urllib.parse
bulldt = timezone.localtime(timezone.now())
def send_aws_email(client, email, subject, content_html, content_txt): def send_aws_email(client, email, subject, content_html, content_txt):
def send_mail(**kwargs): def send_mail(**kwargs):
for i in range(0, 10): for i in range(0, 10):
@ -91,9 +93,9 @@ class Command(BaseCommand):
client = boto3.client('ses', aws_access_key_id=settings.AWS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET, region_name=settings.AWS_REGION) client = boto3.client('ses', aws_access_key_id=settings.AWS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET, region_name=settings.AWS_REGION)
title = '{} News: {}'.format(settings.ORG_NAME, timezone.localtime(timezone.now()).strftime('%d %B %Y')) title = '{} News: {}'.format(settings.ORG_NAME, bulldt.strftime('%d %B %Y'))
calbegin, calend, bulbegin, bulend = sspromotions.utils.bulletin_dates(timezone.localtime(timezone.now())) calbegin, calend, bulbegin, bulend = sspromotions.utils.bulletin_dates(bulldt)
events = list(sspromotions.utils.get_calendar_events(calbegin, calend)) events = list(sspromotions.utils.get_calendar_events(calbegin, calend))
for member in members: for member in members: