membershipworks: Use django.utils.timezone.now instead of django.db.models.functions.Now
All checks were successful
Ruff / ruff (push) Successful in 36s
Test / test (push) Successful in 4m32s

`Now()` produces incorrect results due to timezone mismatch, see
https://code.djangoproject.com/ticket/31638
This commit is contained in:
Adam Goldsmith 2024-05-23 23:43:31 -04:00
parent eeb83388e1
commit c03c5ff2f0

View File

@ -4,7 +4,7 @@ from urllib.parse import quote, urlencode
from django.conf import settings
from django.core import mail
from django.db.models.functions import Now
from django.utils import timezone
from cmsmanage.django_q2_helper import q_task_group
from cmsmanage.email import TemplatedMultipartEmail
@ -62,8 +62,14 @@ class EventSurveyEmail(TemplatedMultipartEmail):
@q_task_group("Send Event Survey Emails")
def send_survey_emails():
with mail.get_connection() as conn:
# not using django.db.models.functions.Now() because of
# timezone mismatch, see
# https://code.djangoproject.com/ticket/31638
for event in EventExt.objects.filter(
occurred=True, should_survey=True, survey_email_sent=False, end__lt=Now()
occurred=True,
should_survey=True,
survey_email_sent=False,
end__lt=timezone.now(),
):
logger.info("Sending survey messages for event: %s", event)