from .ses_send_email import send_email templates = { "subscription_activated": { "subject": "Your subscription to FanSifter is activated", "template": "html/subscription_activated.html", }, "subscription_renewed": { "subject": "Your subscription to FanSifter is renewed", "template": "html/subscription_renewed.html", }, "subscription_canceled": { "subject": "Your subscription to FanSifter is canceled", "template": "html/subscription_canceled.html", }, } attach_images = [ {"name": "fansifter-email-templates/Welcome/g14.png", "cid": "g14_png"} ] def send_subscription_email( template_type, recipient, package_name, billing_cycle=None, active_date=None, next_payment_date=None, ): """Send invite to Data Alliance. Depending on whether invitee exists or not, uses different template""" # default template params template_params = { "active_year": active_date["year"] if active_date else None, "active_month": active_date["month"] if active_date else None, "active_day": active_date["day"] if active_date else None, "next_payment_year": next_payment_date["year"] if next_payment_date else None, "next_payment_month": next_payment_date["month"] if next_payment_date else None, "next_payment_day": next_payment_date["day"] if next_payment_date else None, "billing_cycle": billing_cycle, "package_name": package_name, } email_params = { "sender": '"FanSifter" ', "recipients": recipient, "subject": templates[template_type]["subject"], } send_email( templates[template_type]["template"], template_params, email_params, attach_images, )