Beispiel #1
0
	def test_unsubscribe(self):
		# test unsubscribe
		name = self.send_newsletter()
		from frappe.email.queue import flush
		flush(from_test=True)
		to_unsubscribe = unquote(frappe.local.flags.signed_query_string.split("email=")[1].split("&")[0])

		confirmed_unsubscribe(to_unsubscribe, name)

		name = self.send_newsletter()

		email_queue_list = [frappe.get_doc('Email Queue', e.name) for e in frappe.get_all("Email Queue")]
		self.assertEqual(len(email_queue_list), 3)
		recipients = [e.recipients[0].recipient for e in email_queue_list]
		for email in emails:
			if email != to_unsubscribe:
				self.assertTrue(email in recipients)
Beispiel #2
0
	def test_unsubscribe(self):
		# test unsubscribe
		name = self.send_newsletter()
		from frappe.email.queue import flush
		flush(from_test=True)
		to_unsubscribe = unquote(frappe.local.flags.signed_query_string.split("email=")[1].split("&")[0])

		confirmed_unsubscribe(to_unsubscribe, name)

		name = self.send_newsletter()

		email_queue_list = [frappe.get_doc('Email Queue', e.name) for e in frappe.get_all("Email Queue")]
		self.assertEqual(len(email_queue_list), 3)
		recipients = [e.recipients[0].recipient for e in email_queue_list]
		for email in emails:
			if email != to_unsubscribe:
				self.assertTrue(email in recipients)
Beispiel #3
0
	def test_unsubscribe(self):
		name = self.send_newsletter()
		to_unsubscribe = choice(emails)
		group = frappe.get_all("Newsletter Email Group", filters={"parent": name}, fields=["email_group"])

		flush(from_test=True)
		confirmed_unsubscribe(to_unsubscribe, group[0].email_group)

		name = self.send_newsletter()
		email_queue_list = [
			frappe.get_doc("Email Queue", e.name) for e in frappe.get_all("Email Queue")
		]
		self.assertEqual(len(email_queue_list), 3)
		recipients = [e.recipients[0].recipient for e in email_queue_list]

		for email in emails:
			if email != to_unsubscribe:
				self.assertTrue(email in recipients)
Beispiel #4
0
def get_context(context):
    frappe.flags.ignore_permissions = True
    # Called for confirmation.
    if "email" in frappe.form_dict and frappe.request.method == "GET":
        if verify_request():
            user_email = frappe.form_dict["email"]
            context.email = user_email
            title = frappe.form_dict["name"]
            context.email_groups = get_email_groups(user_email)
            context.current_group = get_current_groups(title)
            context.status = "waiting_for_confirmation"

    # Called when form is submitted.
    elif "user_email" in frappe.form_dict and frappe.request.method == "POST":
        context.status = "unsubscribed"
        email = frappe.form_dict["user_email"]
        email_group = get_email_groups(email)
        for group in email_group:
            if group.email_group in frappe.form_dict:
                confirmed_unsubscribe(email, group.email_group)

    # Called on Invalid or unsigned request.
    else:
        context.status = "invalid"