def _get_send_email_action(self): from shuup.notify.actions import SendEmail current_language = translation.get_language() action_data = { "template_data": {}, "recipient": {"variable": "customer_email"}, "language": {"variable": "language"}, "fallback_language": {"constant": current_language} } # fill the content and subject with the translations for language, __ in settings.LANGUAGES: try: translation.activate(language) action_data["template_data"][language] = { "content_type": content_data.ORDER_CONFIRMATION["content_type"], "subject": force_text(content_data.ORDER_CONFIRMATION["subject"]), "body": template_loader.render_to_string(content_data.ORDER_CONFIRMATION["body_template"]).strip() } except: logger.exception("Failed to translate language %s" % language) action_data["template_data"][language] = { "content_type": "text", "body": " ", "subject": " " } # back to the old language translation.activate(current_language) return SendEmail(action_data)
def get_script_steps(self, form): action_data = { "template_data": {}, "recipient": {"constant": form["base"].cleaned_data["recipient"]}, "language": {"variable": "language"}, "fallback_language": {"constant": settings.PARLER_DEFAULT_LANGUAGE_CODE} } for language in form.forms: form_lang = form[language] # tries to get the cleaned data, otherwise the initial value # since cleaned_data can be blank if the user did not change anything action_data["template_data"][language] = { "content_type": "html", "subject": form_lang.cleaned_data.get("subject", form_lang.initial.get("subject", "")).strip(), "body": form_lang.cleaned_data.get("body", form_lang.initial.get("body", "")).strip() } send_mail_action = SendEmail(action_data) conditions = [] if form["base"].cleaned_data.get("last24hrs"): conditions.append(BooleanEqual({ "v1": {"variable": "dispatched_last_24hs"}, "v2": {"constant": (not form["base"].cleaned_data["last24hrs"])} })) return [Step(next=StepNext.STOP, actions=(send_mail_action,), conditions=conditions)]
def get_script_steps(self, form): action_data = { "template_data": {}, "language": { "constant": settings.PARLER_DEFAULT_LANGUAGE_CODE }, } if form["base"].cleaned_data.get("send_to") == "other": action_data["recipient"] = { "constant": form["base"].cleaned_data["recipient"] } else: action_data["recipient"] = {"variable": "customer_email"} for language in form.forms: form_lang = form[language] # tries to get the cleaned data, otherwise the initial value # since cleaned_data will be blank if the user did not change anything action_data["template_data"][language] = { "content_type": "html", "subject": form_lang.cleaned_data.get( "subject", form_lang.initial.get("subject", "")).strip(), "body": form_lang.cleaned_data.get("body", form_lang.initial.get("body", "")).strip() } send_mail_action = SendEmail(action_data) return [Step(next=StepNext.STOP, actions=(send_mail_action, ))]