diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 63177935382..1e2b352d4ed 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -76,9 +76,9 @@ class JournalEntry(AccountsController): account_type = frappe.db.get_value("Account", d.account, "account_type") if account_type in ["Receivable", "Payable"]: if not (d.party_type and d.party): - frappe.throw(_("Row{0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account)) + frappe.throw(_("Row {0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account)) elif d.party_type and d.party: - frappe.throw(_("Row{0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx)) + frappe.throw(_("Row {0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx)) def check_credit_limit(self): customers = list(set([d.party for d in self.get("accounts") if d.party_type=="Customer" and flt(d.debit) > 0])) @@ -438,7 +438,7 @@ class JournalEntry(AccountsController): if self.stock_entry: if frappe.db.get_value("Stock Entry", self.stock_entry, "docstatus") != 1: frappe.throw(_("Stock Entry {0} is not submitted").format(self.stock_entry)) - + if frappe.db.exists({"doctype": "Journal Entry", "stock_entry": self.stock_entry, "docstatus":1}): frappe.msgprint(_("Warning: Another {0} # {1} exists against stock entry {2}".format(self.voucher_type, self.name, self.stock_entry))) diff --git a/erpnext/crm/doctype/newsletter/newsletter.py b/erpnext/crm/doctype/newsletter/newsletter.py index 0bafda6881b..30fd101e354 100644 --- a/erpnext/crm/doctype/newsletter/newsletter.py +++ b/erpnext/crm/doctype/newsletter/newsletter.py @@ -8,7 +8,9 @@ import frappe.utils from frappe import throw, _ from frappe.model.document import Document from frappe.email.bulk import check_bulk_limit +from frappe.utils.verified_command import get_signed_params, verify_request import erpnext.tasks +from erpnext.crm.doctype.newsletter_list.newsletter_list import add_subscribers class Newsletter(Document): def onload(self): @@ -87,7 +89,6 @@ def get_lead_options(): @frappe.whitelist(allow_guest=True) def unsubscribe(email, name): - from frappe.utils.verified_command import verify_request if not verify_request(): return @@ -123,3 +124,47 @@ def create_lead(email_id): "source": "Email" }) lead.insert() + + +@frappe.whitelist(allow_guest=True) +def subscribe(email): + url = frappe.utils.get_url("/api/method/erpnext.crm.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 id"), + url, + _("Click here to verify") + ) + + print url + + content = """ +
{0}. {1}.
+ + """ + + frappe.sendmail(email, subject=_("Confirm Your Email"), content=content.format(*messages), bulk=True) + +@frappe.whitelist(allow_guest=True) +def confirm_subscription(email): + if not verify_request(): + return + + if not frappe.db.exists("Newsletter List", _("Website")): + frappe.get_doc({ + "doctype": "Newsletter List", + "title": _("Website") + }).insert(ignore_permissions=True) + + + frappe.flags.ignore_permissions = True + + add_subscribers(_("Website"), email) + frappe.db.commit() + + frappe.respond_as_web_page(_("Confirmed"), _("{0} has been successfully added to our Newsletter list.").format(email)) + + + diff --git a/erpnext/crm/doctype/newsletter_list/newsletter_list.py b/erpnext/crm/doctype/newsletter_list/newsletter_list.py index e4ba6b1ad44..1eb95eac172 100644 --- a/erpnext/crm/doctype/newsletter_list/newsletter_list.py +++ b/erpnext/crm/doctype/newsletter_list/newsletter_list.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document -from frappe.utils import validate_email_add, strip +from frappe.utils import validate_email_add from frappe import _ from email.utils import parseaddr @@ -75,7 +75,7 @@ def add_subscribers(name, email_list): "doctype": "Newsletter List Subscriber", "newsletter_list": name, "email": email - }).insert() + }).insert(ignore_permissions = frappe.flags.ignore_permissions) count += 1 else: diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 74631d170a5..bc7f9d5c44e 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -96,9 +96,10 @@ scheduler_events = { ] } -default_mail_footer = """