From bcb3382f4fc6deeba3011c9c7433dd519a4e5e95 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 14 Feb 2013 13:36:41 +0530 Subject: [PATCH] fixes in assign to url --- webnotes/utils/__init__.py | 12 ++++++++++++ webnotes/widgets/form/assign_to.py | 11 ++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index 4c803206d8..7c6ac9a920 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -780,3 +780,15 @@ def get_base_path(): import conf import os return os.path.dirname(os.path.abspath(conf.__file__)) + +def get_url_to_form(doctype, name, base_url=None, label=None): + if not base_url: + try: + from startup import get_url + base_url = get_url() + except ImportError: + base_url = get_request_site_address() + + if not label: label = name + + return """%(label)s""" % locals() \ No newline at end of file diff --git a/webnotes/widgets/form/assign_to.py b/webnotes/widgets/form/assign_to.py index 2efdae8b95..60b1c2c669 100644 --- a/webnotes/widgets/form/assign_to.py +++ b/webnotes/widgets/form/assign_to.py @@ -111,15 +111,8 @@ def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', no user_info = get_fullnames() # Search for email address in description -- i.e. assignee - try: - from startup import get_url - url = get_url() - except ImportError: - from webnotes.utils import get_request_site_address - url = get_request_site_address() - - assignment = """%s: %s""" % (url, - doc_type, doc_name, doc_type, doc_name) + from webnotes.utils import get_url_to_form + assignment = get_url_to_form(doc_type, doc_name, label="%s: %s" % (doc_type, doc_name)) if action=='CLOSE': if owner == webnotes.session.get('user'):