From 7aedaec6b60550902175e1a2120b023698d00d22 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 16 Oct 2012 10:47:18 +0530 Subject: [PATCH] added get_site_address method to website's init --- accounts/doctype/gl_control/gl_control.py | 20 +++++++++----------- setup/doctype/setup_control/setup_control.py | 4 ++-- website/__init__.py | 14 +++++++++++++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/accounts/doctype/gl_control/gl_control.py b/accounts/doctype/gl_control/gl_control.py index 71d5a0b252..f0c76eb822 100644 --- a/accounts/doctype/gl_control/gl_control.py +++ b/accounts/doctype/gl_control/gl_control.py @@ -439,13 +439,7 @@ def manage_recurring_invoices(): def notify_errors(inv, owner): import webnotes - from webnotes.utils import get_request_site_address - url = get_request_site_address() - if not url or url=='http://localhost': - new_url = webnotes.conn.get_value('Website Settings', 'Website Settings', - 'subdomain') - if new_url: - url = new_url + import website exception_msg = """ Dear User, @@ -467,11 +461,15 @@ def notify_errors(inv, owner): Regards, Administrator - """ % (inv, url, inv) + """ % (inv, website.get_site_address(), inv) subj = "[Urgent] Error while creating recurring invoice from %s" % inv - import webnotes.utils - recipients = webnotes.utils.get_system_managers_list() - recipients += [webnotes.conn.get_value("Profile", owner, "email")] + + from webnotes.profile import get_system_managers + recipients = get_system_managers() + owner_email = webnotes.conn.get_value("Profile", owner, "email") + if not owner_email in recipients: + recipients.append(owner_email) + assign_task_to_owner(inv, exception_msg, recipients) sendmail(recipients, subject=subj, msg = exception_msg) diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index b5207c2f08..a71fde95c4 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -140,8 +140,8 @@ class DocType: import webnotes companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1) - import webnotes.utils - system_managers = webnotes.utils.get_system_managers_list() + from webnotes.profile import get_system_managers + system_managers = get_system_managers() if not system_managers: return from webnotes.model.doc import Document diff --git a/website/__init__.py b/website/__init__.py index dbf65dd04d..0796fb4764 100644 --- a/website/__init__.py +++ b/website/__init__.py @@ -23,4 +23,16 @@ def send_message(): webnotes.msgprint('Please give us your email id so that we can write back to you', raise_exception=True) d.save() - webnotes.msgprint('Thank you!') \ No newline at end of file + webnotes.msgprint('Thank you!') + +def get_site_address(): + from webnotes.utils import get_request_site_address + url = get_request_site_address() + + if not url or url=='http://localhost': + new_url = webnotes.conn.get_value('Website Settings', 'Website Settings', + 'subdomain') + if new_url: + url = "http://" + new_url + + return url \ No newline at end of file