def get_unsubcribed_url(reference_doctype, reference_name, email, unsubscribe_method, unsubscribe_params): params = {"email": email.encode("utf-8"), "doctype": reference_doctype.encode("utf-8"), "name": reference_name.encode("utf-8")} if unsubscribe_params: params.update(unsubscribe_params) query_string = get_signed_params(params) # for test frappe.local.flags.signed_query_string = query_string return get_url(unsubscribe_method + "?" + get_signed_params(params))
def unsubscribe(email, name): if not verify_request(): return primary_action = frappe.utils.get_url() + "/api/method/frappe.email.doctype.newsletter.newsletter.confirmed_unsubscribe"+\ "?" + get_signed_params({"email": email, "name":name}) return_confirmation_page(email, name, primary_action)
def generate_file_and_send_mail(self, personal_data): """generate the file link for download""" user_name = self.user_name.replace(' ', '-') f = frappe.get_doc({ 'doctype': 'File', 'file_name': 'Personal-Data-' + user_name + '-' + self.name + '.json', "attached_to_doctype": 'Personal Data Download Request', "attached_to_name": self.name, 'content': str(personal_data), 'is_private': 1 }) f.save(ignore_permissions=True) file_link = frappe.utils.get_url("/api/method/frappe.utils.file_manager.download_file") +\ "?" + get_signed_params({"file_url": f.file_url}) host_name = frappe.local.site frappe.sendmail(recipients=self.user, subject=_("Download Your Data"), template="download_data", args={ 'user': self.user, 'user_name': self.user_name, 'link': file_link, 'host_name': host_name }, header=[_("Download Your Data"), "green"])
def get_unsubcribed_url(reference_doctype, reference_name, email, unsubscribe_method, unsubscribe_params): params = { "email": email.encode("utf-8"), "doctype": reference_doctype.encode("utf-8"), "name": reference_name.encode("utf-8") } if unsubscribe_params: params.update(unsubscribe_params) query_string = get_signed_params(params) # for test frappe.local.flags.signed_query_string = query_string return get_url(unsubscribe_method + "?" + get_signed_params(params))
def get_confirm_workflow_action_url(doc, action, user): confirm_action_method = "/api/method/frappe.workflow.doctype.workflow_action.workflow_action.confirm_action" params = { "action": action, "doctype": doc.get('doctype'), "docname": doc.get('name'), "user": user } return get_url(confirm_action_method + "?" + get_signed_params(params))
def get_confirm_workflow_action_url(doc, action, user): confirm_action_method = "/api/method/frappe.workflow.doctype.workflow_action.workflow_action.confirm_action" params = { "action": action, "doctype": doc.get('doctype'), "docname": doc.get('name'), "user": user } return get_url(confirm_action_method + "?" + get_signed_params(params))
def get_workflow_action_url(action, doc, user): apply_action_method = "/api/method/frappe.workflow.doctype.workflow_action.workflow_action.apply_action" params = { "doctype": doc.get('doctype'), "docname": doc.get('name'), "action": action, "current_state": get_doc_workflow_state(doc), "user": user, "last_modified": doc.get('modified') } return get_url(apply_action_method + "?" + get_signed_params(params))
def get_workflow_action_url(action, doc, user): apply_action_method = "/api/method/frappe.workflow.doctype.workflow_action.workflow_action.apply_action" params = { "doctype": doc.get('doctype'), "docname": doc.get('name'), "action": action, "current_state": get_doc_workflow_state(doc), "user": user, "last_modified": doc.get('modified') } return get_url(apply_action_method + "?" + get_signed_params(params))
def send_verification_mail(self): host_name = frappe.local.site url = frappe.utils.get_url("/api/method/frappe.website.doctype.personal_data_deletion_request.personal_data_deletion_request.confirm_deletion") +\ "?" + get_signed_params({"email": self.email, "name": self.name, 'host_name': host_name}) frappe.sendmail(recipients=self.email, subject=_("Confirm Deletion of Data"), template="delete_data_confirmation", args={ 'email': self.email, 'name': self.name, 'host_name': host_name, 'link': url }, header=[_("Confirm Deletion of Data"), "green"])
def subscribe(email, email_group=_("Website")): """API endpoint to subscribe an email to a particular email group. Triggers a confirmation email. """ # build subscription confirmation URL api_endpoint = frappe.utils.get_url( "/api/method/frappe.email.doctype.newsletter.newsletter.confirm_subscription" ) signed_params = get_signed_params({ "email": email, "email_group": email_group }) confirm_subscription_url = f"{api_endpoint}?{signed_params}" # fetch custom template if available email_confirmation_template = frappe.db.get_value( "Email Group", email_group, "confirmation_email_template") # build email and send if email_confirmation_template: args = { "email": email, "confirmation_url": confirm_subscription_url, "email_group": email_group } email_template = frappe.get_doc("Email Template", email_confirmation_template) email_subject = email_template.subject content = frappe.render_template(email_template.response, args) else: email_subject = _("Confirm Your Email") translatable_content = ( _("Thank you for your interest in subscribing to our updates"), _("Please verify your Email Address"), confirm_subscription_url, _("Click here to verify"), ) content = """ <p>{0}. {1}.</p> <p><a href="{2}">{3}</a></p> """.format(*translatable_content) frappe.sendmail( email, subject=email_subject, content=content, now=True, )
def subscribe(email): url = frappe.utils.get_url("/api/method/frappe.email.doctype.newsletter.newsletter.confirm_subscription") +\ "?" + get_signed_params({"email": email}) messages = (_("Thank you for your interest in subscribing to our updates"), _("Please verify your Email Address"), url, _("Click here to verify")) content = """ <p>{0}. {1}.</p> <p><a href="{2}">{3}</a></p> """ frappe.sendmail(email, subject=_("Confirm Your Email"), content=content.format(*messages))
def subscribe(email): url = frappe.utils.get_url("/api/method/frappe.email.doctype.newsletter.newsletter.confirm_subscription") +\ "?" + get_signed_params({"email": email}) messages = ( _("Thank you for your interest in subscribing to our updates"), _("Please verify your Email Address"), url, _("Click here to verify") ) content = """ <p>{0}. {1}.</p> <p><a href="{2}">{3}</a></p> """ frappe.sendmail(email, subject=_("Confirm Your Email"), content=content.format(*messages))
def subscribe(email): from frappe.utils.verified_command import get_signed_params url = "{0}?{1}".format( frappe.utils.get_url( "/api/method/egd_site.tools.confirm_subscription"), get_signed_params({ "email": email, "_lang": frappe.local.lang })) messages = (_("newsletter:email:body:verify_your_email"), url, _("newsletter:email:body:click_here_to_verify")) content = "<p>{0}</p><p><a href=\"{1}\">{2}</a></p>".format(*messages) frappe.sendmail(email, subject=_("newsletter:email:subject"), content=content, delayed=False)
def _get_verify_url(self): verify_route = '/book_appointment/verify' params = {'email': self.customer_email, 'appointment': self.name} return get_url(verify_route + '?' + get_signed_params(params))
def _get_verify_url(self): verify_route = "/book_appointment/verify" params = {"email": self.customer_email, "appointment": self.name} return get_url(verify_route + "?" + get_signed_params(params))