Added modal to Action button on Lead DocType form to allow users to add Leads to Email Groups for newsletters and minor changes to CSS
This commit is contained in:
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
from frappe.utils import today
|
||||
from frappe import _
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_lead_to_campaign(lead_name, campaign_name, start_date=None):
|
||||
@ -29,3 +30,32 @@ def add_lead_to_campaign(lead_name, campaign_name, start_date=None):
|
||||
frappe.db.commit()
|
||||
|
||||
return {"status": "success", "message": "Email Campaign created"}
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_lead_to_email_group(lead_name, email_group):
|
||||
if not lead_name or not email_group:
|
||||
return {"status": "error", "message": _("Missing required parameters.")}
|
||||
|
||||
lead = frappe.get_doc("Lead", lead_name)
|
||||
|
||||
if not lead.email_id:
|
||||
return {"status": "error", "message": _("Lead does not have an email address.")}
|
||||
|
||||
# Check if already added
|
||||
exists = frappe.db.exists(
|
||||
"Email Group Member",
|
||||
{"email": lead.email_id, "email_group": email_group}
|
||||
)
|
||||
if exists:
|
||||
return {"status": "error", "message": _("Lead is already in this Email Group.")}
|
||||
|
||||
# Add to email group
|
||||
frappe.get_doc({
|
||||
"doctype": "Email Group Member",
|
||||
"email_group": email_group,
|
||||
"email": lead.email_id,
|
||||
"status": "Subscribed"
|
||||
}).insert(ignore_permissions=True)
|
||||
|
||||
return {"status": "success"}
|
||||
Reference in New Issue
Block a user