diff --git a/core/doctype/profile/profile.py b/core/doctype/profile/profile.py index ed1718ae22..b6d8ca671b 100644 --- a/core/doctype/profile/profile.py +++ b/core/doctype/profile/profile.py @@ -100,11 +100,11 @@ class DocType: webnotes.conn.set(self.doc, 'new_password', '') def reset_password(self): - from webnotes.utils import random_string, get_request_site_address + from webnotes.utils import random_string, get_url key = random_string(32) webnotes.conn.set_value("Profile", self.doc.name, "reset_password_key", key) - self.password_reset_mail(get_request_site_address() + "/update-password?key=" + key) + self.password_reset_mail(get_url("/update-password?key=" + key)) def get_other_system_managers(self): return webnotes.conn.sql("""select distinct parent from tabUserRole user_role @@ -179,7 +179,7 @@ Thank you,
from webnotes.utils.email_lib import sendmail_md from webnotes.profile import get_user_fullname - from webnotes.utils import get_request_site_address + from webnotes.utils import get_url full_name = get_user_fullname(webnotes.session['user']) if full_name == "Guest": @@ -189,7 +189,7 @@ Thank you,
'first_name': self.doc.first_name or self.doc.last_name or "user", 'user': self.doc.name, 'company': webnotes.conn.get_default('company') or webnotes.get_config().get("app_name"), - 'login_url': get_request_site_address(), + 'login_url': get_url(), 'product': webnotes.get_config().get("app_name"), 'user_fullname': full_name } diff --git a/core/page/messages/messages.py b/core/page/messages/messages.py index b1db17e51e..8caddba648 100644 --- a/core/page/messages/messages.py +++ b/core/page/messages/messages.py @@ -80,8 +80,7 @@ def delete(arg=None): webnotes.form_dict['name']); def notify(arg=None): - from webnotes.utils import cstr, get_fullname - from startup import get_url + from webnotes.utils import cstr, get_fullname, get_url fn = get_fullname(webnotes.user.name) or webnotes.user.name diff --git a/public/js/wn/model/meta.js b/public/js/wn/model/meta.js index d51775ed60..7c5b1c456a 100644 --- a/public/js/wn/model/meta.js +++ b/public/js/wn/model/meta.js @@ -117,7 +117,7 @@ $.extend(wn.meta, { var currency = wn.boot.sysdefaults.currency; if(!doc && cur_frm) doc = cur_frm.doc; - + if(df && df.options) { if(doc && df.options.indexOf(":")!=-1) { var options = df.options.split(":"); @@ -127,7 +127,9 @@ $.extend(wn.meta, { if(!docname && cur_frm) { docname = cur_frm.doc[options[1]]; } - currency = wn.model.get_value(options[0], docname, options[2]) || currency; + currency = wn.model.get_value(options[0], docname, options[2]) || + wn.model.get_value(":" + options[0], docname, options[2]) || + currency; } } else if(doc && doc[df.options]) { currency = doc[df.options]; diff --git a/public/js/wn/views/query_report.js b/public/js/wn/views/query_report.js index 1e967848a7..c7a2cc4a81 100644 --- a/public/js/wn/views/query_report.js +++ b/public/js/wn/views/query_report.js @@ -188,9 +188,9 @@ wn.views.QueryReport = Class.extend({ if(c.indexOf(":")!=-1) { var opts = c.split(":"); var df = { - label: opts.slice(0, opts.length - 2).join(":"), - fieldtype: opts[opts.length - 2], - width: opts[opts.length - 1] + label: opts.length<=2 ? opts[0] : opts.slice(0, opts.length - 2).join(":"), + fieldtype: opts.length<=2 ? opts[1] : opts[opts.length - 2], + width: opts.length<=2 ? opts[2] : opts[opts.length - 1] } if(!df.fieldtype) diff --git a/webnotes/__init__.py b/webnotes/__init__.py index b275442edb..2cdc069a05 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -302,9 +302,8 @@ def has_permission(doctype, ptype="read", refdoc=None): keys = p.match.split(":") else: keys = [p.match, p.match] - - if refdoc.fields.get(keys[0],"[No Value]") \ - in get_user_default_as_list(keys[1]): + + if refdoc.fields.get(keys[0],"[No Value]") in get_user_default_as_list(keys[1]): return True else: match_failed[keys[0]] = refdoc.fields.get(keys[0],"[No Value]") @@ -320,6 +319,7 @@ def has_permission(doctype, ptype="read", refdoc=None): msg += "\n" + (doctypelist.get_field(key) and doctypelist.get_label(key) or key) \ + " = " + (match_failed[key] or "None") msgprint(msg) + return False else: return perms and True or False diff --git a/webnotes/handler.py b/webnotes/handler.py index 6cf15eab7d..f8747206af 100755 --- a/webnotes/handler.py +++ b/webnotes/handler.py @@ -30,6 +30,7 @@ def web_logout(): webnotes.repsond_as_web_page("Logged Out", """

You have been logged out.

Back to Home

""") webnotes.local.login_manager.logout() + webnotes.commit() @webnotes.whitelist() def uploadfile(): diff --git a/webnotes/test_runner.py b/webnotes/test_runner.py index 16bf19c21e..ed5b00f55f 100644 --- a/webnotes/test_runner.py +++ b/webnotes/test_runner.py @@ -50,7 +50,6 @@ def get_dependencies(doctype): for doctype_name in test_module.test_ignore: if doctype_name in options_list: options_list.remove(doctype_name) - return options_list def make_test_records_for_doctype(doctype, verbose=0): diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index eec00864a0..cab05665bf 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -816,13 +816,19 @@ def get_base_path(): import os return os.path.dirname(os.path.abspath(conf.__file__)) -def get_url(): - import startup - if hasattr(startup, "get_url"): - url = startup.get_url() - else: - url = get_request_site_address() - +def get_url(uri=None): + url = get_request_site_address() + if not url or "localhost" in url: + subdomain = webnotes.conn.get_value("Website Settings", "Website Settings", + "subdomain") + if subdomain: + if "http" not in subdomain: + url = "http://" + subdomain + + if uri: + import urllib + url = urllib.basejoin(url, uri) + return url def get_url_to_form(doctype, name, base_url=None, label=None): diff --git a/webnotes/utils/email_lib/bulk.py b/webnotes/utils/email_lib/bulk.py index 542fee1a85..4756ce7eba 100644 --- a/webnotes/utils/email_lib/bulk.py +++ b/webnotes/utils/email_lib/bulk.py @@ -33,12 +33,12 @@ def send(recipients=None, sender=None, doctype='Profile', email_field='email', raise_exception=BulkLimitCrossedError) def update_message(doc): - from webnotes.utils import get_request_site_address + from webnotes.utils import get_url import urllib updated = message + """
- Unsubscribe from this list.
""" % (get_request_site_address(), + Unsubscribe from this list.""" % (get_url(), urllib.urlencode({ "cmd": "webnotes.utils.email_lib.bulk.unsubscribe", "email": doc.get(email_field), diff --git a/webnotes/utils/scheduler.py b/webnotes/utils/scheduler.py index f5db923717..d98564c52a 100644 --- a/webnotes/utils/scheduler.py +++ b/webnotes/utils/scheduler.py @@ -103,7 +103,7 @@ def log(method): def report_errors(): from webnotes.utils.email_lib import sendmail_to_system_managers - from startup import get_url + from webnotes.utils import get_url errors = [("""

Time: %(modified)s

%(error)s
""" % d) for d in webnotes.conn.sql("""select modified, error diff --git a/webnotes/utils/webclient.py b/webnotes/utils/webclient.py deleted file mode 100644 index 69a1fa67fe..0000000000 --- a/webnotes/utils/webclient.py +++ /dev/null @@ -1,146 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# MIT License. See license.txt - -# Simple Web service client for wnframework (ERPNext) -# License MIT -# -# Uses: requests (http://docs.python-requests.org/en/v1.0.0/) -# -# Usage: -# 1. set the server settings, user, password in this file -# 2. user the "insert", "update", "delete" methods to push data -# -# Help: -# Data is sent as JSON objects called "doclist". A doclist is a list of records that represent one transaction (document) -# in ERPNext, both parent (header) and child records. -# -# For what fields to set in the doclist, please check the table columns of the table you want to update - -import requests -import unittest -import json - -server = "http://localhost/webnotes/erpnext_master/public/server.py" -user = "Administrator" -password = "test" -sid = None -debug = True - -class AuthError(Exception): pass - -def login(usr=None, pwd=None): - response = requests.get(server, params = { - "cmd": "login", - "usr": usr or user, - "pwd": pwd or password - }) - - if response.json.get("message")=="Logged In": - global sid - sid = response.cookies["sid"] - return response - else: - raise AuthError - -def insert(doclist): - return post_request({ - "cmd": "webnotes.client.insert", - "doclist": json.dumps(doclist) - }) - -def update(doclist): - return post_request({ - "cmd": "webnotes.client.save", - "doclist": json.dumps(doclist) - }) - -def delete(doctype, name): - return post_request({ - "cmd": "webnotes.model.delete_doc", - "doctype": doctype, - "name": name - }) - -def submit(doclist): - return post_request({ - "cmd": "webnotes.client.submit", - "doclist": json.dumps(doclist) - }) - - -def cancel(doctype, name): - return post_request({ - "cmd": "webnotes.client.cancel", - "doctype": doctype, - "name": name - }) - -def get_doc(doctype, name=None, filters=None): - params = { - "cmd": "webnotes.client.get", - "doctype": doctype, - } - if name: - params["name"] = name - if filters: - params["filters"] = json.dumps(filters) - ret = get_request(params) - return ret - -def get_request(params): - if not sid: login() - response = requests.get(server, params = params, cookies = {"sid": sid}) - return post_process(response) - -def post_request(params): - if not sid: login() - response = requests.post(server, data = params, cookies = {"sid": sid}) - return post_process(response) - -def post_process(response): - if debug and response.json and ("exc" in response.json) and response.json["exc"]: - print response.json["exc"] - - return response - -class TestAPI(unittest.TestCase): - def test_login(self): - global sid - response = login() - self.assertTrue(response.json.get("message")=="Logged In") - self.assertTrue(sid) - self.assertRaises(AuthError, login, {"pwd":"--"}) - sid = None - - def test_all(self): - login() - delete("Customer", "Import Test Customer") - response = insert([{ - "doctype":"Customer", - "customer_name": "Import Test Customer", - "customer_type": "Company", - "customer_group": "Standard Group", - "territory": "Default", - "customer_details": "some unique info", - "company": "Alpha" - }]) - self.assertTrue(response.json["message"][0]["name"]=="Import Test Customer") - - # get - response = get_doc("Customer", "Import Test Customer") - self.check_get(response) - - response = get_doc("Customer", filters={"customer_details":"some unique info"}) - self.check_get(response) - - # delete - self.assertTrue(delete("Customer", "Import Test Customer").json["message"]=="okay") - - def check_get(self, response): - doclist = response.json["message"] - self.assertTrue(len(doclist)==1) - self.assertTrue(doclist[0]["doctype"]=="Customer") - self.assertTrue(doclist[0]["customer_group"]=="Standard Group") - -if __name__=="__main__": - unittest.main() \ No newline at end of file diff --git a/website/__init__.py b/website/__init__.py index aace68bb64..631b10f0b2 100644 --- a/website/__init__.py +++ b/website/__init__.py @@ -5,16 +5,3 @@ install_docs = [ ] import webnotes - - -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 diff --git a/website/doctype/website_item_group/README.md b/website/doctype/website_item_group/README.md deleted file mode 100644 index 54abfaf4fb..0000000000 --- a/website/doctype/website_item_group/README.md +++ /dev/null @@ -1 +0,0 @@ -Alternate grouping of parent Item (for website, so an Item can be listed under multiple groups). \ No newline at end of file diff --git a/website/doctype/website_item_group/__init__.py b/website/doctype/website_item_group/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/website_item_group/website_item_group.py b/website/doctype/website_item_group/website_item_group.py deleted file mode 100644 index 3256c80d42..0000000000 --- a/website/doctype/website_item_group/website_item_group.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# MIT License. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/website_item_group/website_item_group.txt b/website/doctype/website_item_group/website_item_group.txt deleted file mode 100644 index 3d26e85315..0000000000 --- a/website/doctype/website_item_group/website_item_group.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:09", - "docstatus": 0, - "modified": "2013-07-10 14:54:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Cross Listing of Item in multiple groups", - "doctype": "DocType", - "document_type": "Other", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Group", - "name": "__common__", - "options": "Item Group", - "parent": "Website Item Group", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Website Item Group" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file