From 350dc4e1ee2056c9f9121bdda52398cc95453db6 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 23 May 2024 19:41:30 -0400 Subject: [PATCH] membershipworks: Inline event survey_url function --- membershipworks/tasks/event_survey_emails.py | 32 +++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/membershipworks/tasks/event_survey_emails.py b/membershipworks/tasks/event_survey_emails.py index 88d421b..7772a34 100644 --- a/membershipworks/tasks/event_survey_emails.py +++ b/membershipworks/tasks/event_survey_emails.py @@ -21,27 +21,29 @@ class EventSurveyEmail(TemplatedMultipartEmail): 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 def render_for_event(cls, event: EventExt) -> Iterable[mail.EmailMessage]: for name, email in event.attendees.values_list("name", "email"): sanitized_email = mail.message.sanitize_address( (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( {"event": event, "attendee_name": name, "survey_url": survey_url}, to=[sanitized_email],