From bd1e009cc26c8a7508ebe03770d176009ee59c5f Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 23 May 2024 19:42:57 -0400 Subject: [PATCH] membershipworks: Only send event survey emails to non-voided participants --- membershipworks/tasks/event_survey_emails.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/membershipworks/tasks/event_survey_emails.py b/membershipworks/tasks/event_survey_emails.py index 7772a34..79dd254 100644 --- a/membershipworks/tasks/event_survey_emails.py +++ b/membershipworks/tasks/event_survey_emails.py @@ -23,7 +23,15 @@ class EventSurveyEmail(TemplatedMultipartEmail): @classmethod def render_for_event(cls, event: EventExt) -> Iterable[mail.EmailMessage]: - for name, email in event.attendees.values_list("name", "email"): + # not using event.attendees because that makes getting ticket count harder + for attendee in event.details["usr"]: + # skip users with no tickets, as they were Voided + if sum(attendee["tkt"]) == 0: + continue + + name = attendee["nam"] + email = attendee["eml"] + sanitized_email = mail.message.sanitize_address( (name, email), settings.DEFAULT_CHARSET )