membershipworks: Only send event survey emails to non-voided participants
All checks were successful
Ruff / ruff (push) Successful in 28s
Test / test (push) Successful in 4m5s

This commit is contained in:
Adam Goldsmith 2024-05-23 19:42:57 -04:00
parent 350dc4e1ee
commit bd1e009cc2

View File

@ -23,7 +23,15 @@ class EventSurveyEmail(TemplatedMultipartEmail):
@classmethod @classmethod
def render_for_event(cls, event: EventExt) -> Iterable[mail.EmailMessage]: 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( sanitized_email = mail.message.sanitize_address(
(name, email), settings.DEFAULT_CHARSET (name, email), settings.DEFAULT_CHARSET
) )