Compare commits

..

2 Commits

Author SHA1 Message Date
bd1e009cc2 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
2024-05-23 19:42:57 -04:00
350dc4e1ee membershipworks: Inline event survey_url function 2024-05-23 19:41:57 -04:00

View File

@ -21,27 +21,37 @@ class EventSurveyEmail(TemplatedMultipartEmail):
template = "membershipworks/email/event_survey.dj.html" template = "membershipworks/email/event_survey.dj.html"
@staticmethod
def survey_url(event: EventExt, attendee_name: str, attendee_email: str) -> str:
return "https://claremontmakerspace.org/class-evaluation-form?" + urlencode(
{
"event_id": event.eid,
"instructor_name": str(event.instructor) if event.instructor else "",
"event_name": event.title,
"event_date": event.start.strftime("%Y-%m-%d %H:%M:%S"),
"participant_name": attendee_name,
"participant_email": attendee_email,
},
quote_via=quote,
)
@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
) )
survey_url = cls.survey_url(event, name, email) survey_url = (
"https://claremontmakerspace.org/class-evaluation-form?"
+ urlencode(
{
"event_id": event.eid,
"instructor_name": (
str(event.instructor) if event.instructor else ""
),
"event_name": event.title,
"event_date": event.start.strftime("%Y-%m-%d %H:%M:%S"),
"participant_name": name,
"participant_email": email,
},
quote_via=quote,
)
)
yield cls.render( yield cls.render(
{"event": event, "attendee_name": name, "survey_url": survey_url}, {"event": event, "attendee_name": name, "survey_url": survey_url},
to=[sanitized_email], to=[sanitized_email],