membershipworks: Inline event survey_url function

This commit is contained in:
Adam Goldsmith 2024-05-23 19:41:30 -04:00
parent dcf483d19e
commit 350dc4e1ee

View File

@ -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],