Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: require sender and message for contact us page #34707

Merged
merged 2 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

override_doctype_class = {"Address": "erpnext.accounts.custom.address.ERPNextAddress"}

override_whitelisted_methods = {
"frappe.www.contact.send_message": "erpnext.templates.utils.send_message"
}

welcome_email = "erpnext.setup.utils.welcome_email"

# setup wizard
Expand Down
15 changes: 0 additions & 15 deletions erpnext/public/js/website_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@

if(!window.erpnext) window.erpnext = {};

// Add / update a new Lead / Communication
// subject, sender, description
frappe.send_message = function(opts, btn) {
return frappe.call({
type: "POST",
method: "erpnext.templates.utils.send_message",
btn: btn,
args: opts,
callback: opts.callback
});
};

erpnext.subscribe_to_newsletter = function(opts, btn) {
return frappe.call({
type: "POST",
Expand All @@ -24,6 +12,3 @@ erpnext.subscribe_to_newsletter = function(opts, btn) {
callback: opts.callback
});
}

// for backward compatibility
erpnext.send_message = frappe.send_message;
9 changes: 3 additions & 6 deletions erpnext/templates/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@


@frappe.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
def send_message(sender, message, subject="Website Query"):
from frappe.www.contact import send_message as website_send_message

lead = customer = None

website_send_message(subject, message, sender)
website_send_message(sender, message, subject)

lead = customer = None
customer = frappe.db.sql(
"""select distinct dl.link_name from `tabDynamic Link` dl
left join `tabContact` c on dl.parent=c.name where dl.link_doctype='Customer'
Expand Down Expand Up @@ -58,5 +57,3 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
}
)
comm.insert(ignore_permissions=True)

return "okay"