diff --git a/frappe/__init__.py b/frappe/__init__.py
index 50cac5b698..2062004296 100644
--- a/frappe/__init__.py
+++ b/frappe/__init__.py
@@ -548,12 +548,14 @@ def compare(val1, condition, val2):
import frappe.utils
return frappe.utils.compare(val1, condition, val2)
-def respond_as_web_page(title, html, success=None):
+def respond_as_web_page(title, html, success=None, http_status_code=None):
local.message_title = title
local.message = html
local.message_success = success
local.response['type'] = 'page'
local.response['page_name'] = 'message.html'
+ if http_status_code:
+ local.response['http_status_code'] = http_status_code
def build_match_conditions(doctype, as_condition=True):
import frappe.widgets.reportview
diff --git a/frappe/core/page/desktop/desktop.js b/frappe/core/page/desktop/desktop.js
index 3800f63de9..3d5b0c42ba 100644
--- a/frappe/core/page/desktop/desktop.js
+++ b/frappe/core/page/desktop/desktop.js
@@ -215,7 +215,7 @@ frappe.desktop.show_pending_notifications = function() {
sum = frappe.boot.notification_info.open_count_module[module];
}
if (frappe.modules[module]) {
- var notifier = $("#module-count-" + frappe.modules[module]._id);
+ var notifier = $("#module-count-" + frappe.desktop.get_module(module)._id);
if(notifier.length) {
notifier.toggle(sum ? true : false);
notifier.find(".circle-text").html(sum || "");
diff --git a/frappe/templates/emails/password_reset.html b/frappe/templates/emails/password_reset.html
index ecfd987191..084361dd41 100644
--- a/frappe/templates/emails/password_reset.html
+++ b/frappe/templates/emails/password_reset.html
@@ -1,6 +1,7 @@
Password Reset
+
Dear {{ first_name }}{% if last_name %} {{ last_name}}{% endif %},
-Please click on the following link to update your new password:
+Please click on the following link to set your new password:
{{ link }}
Thank you,
{{ user_fullname }}
\ No newline at end of file
diff --git a/frappe/templates/pages/update-password.html b/frappe/templates/pages/update-password.html
index dcccd80b86..6b48361013 100644
--- a/frappe/templates/pages/update-password.html
+++ b/frappe/templates/pages/update-password.html
@@ -1,5 +1,8 @@
{% block title %} Reset Password {% endblock %}
+{% block header %}{% endblock %}
+{% block breadcrumbs %}{% endblock %}
+
{% block content %}
diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py
index b74fd9e1a7..7711a84372 100644
--- a/frappe/utils/__init__.py
+++ b/frappe/utils/__init__.py
@@ -67,24 +67,6 @@ def validate_email_add(email_str):
email = extract_email_id(email_str)
return re.match("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", email.lower())
-def get_request_site_address(full_address=False):
- """get app url from request"""
- host_name = frappe.local.conf.host_name
-
- if not host_name:
- if frappe.request:
- protocol = 'https' == frappe.get_request_header('X-Forwarded-Proto', "") and 'https://' or 'http://'
- host_name = protocol + frappe.request.host
- elif frappe.local.site:
- return "http://" + frappe.local.site
- else:
- return "http://localhost"
-
- if full_address:
- return host_name + frappe.get_request_header("REQUEST_URI", "")
- else:
- return host_name
-
def random_string(length):
"""generate a random string"""
import string
@@ -817,19 +799,34 @@ def get_files_path():
return get_site_path("public", "files")
def get_backups_path():
- return get_site_path("private", "backups")
-
-def get_url(uri=None):
- url = get_request_site_address()
- if not url or "localhost" in url:
- subdomain = frappe.db.get_value("Website Settings", "Website Settings",
- "subdomain")
- if subdomain:
- if "http" not in subdomain:
- url = "http://" + subdomain
+ return get_site_path("private", "backups")
+
+def get_request_site_address(full_address=False):
+ return get_url(full_address=full_address)
+
+def get_url(uri=None, full_address=False):
+ """get app url from request"""
+ host_name = frappe.local.conf.host_name
+
+ if not host_name:
+ if hasattr(frappe.local, "request") and frappe.local.request and frappe.local.request.host:
+ protocol = 'https' == frappe.get_request_header('X-Forwarded-Proto', "") and 'https://' or 'http://'
+ host_name = protocol + frappe.local.request.host
+ elif frappe.local.site:
+ host_name = "http://{}".format(frappe.local.site)
+ else:
+ host_name = frappe.db.get_value("Website Settings", "Website Settings",
+ "subdomain")
+ if host_name and "http" not in host_name:
+ host_name = "http://" + host_name
- if uri:
- url = urllib.basejoin(url, uri)
+ if not host_name:
+ host_name = "http://localhost"
+
+ if not uri and full_address:
+ uri = frappe.get_request_header("REQUEST_URI", "")
+
+ url = urllib.basejoin(host_name, uri) if uri else host_name
return url
diff --git a/frappe/utils/response.py b/frappe/utils/response.py
index 3186bafe9a..d675d3ad1f 100644
--- a/frappe/utils/response.py
+++ b/frappe/utils/response.py
@@ -116,7 +116,7 @@ def json_handler(obj):
def as_page():
"""print web page"""
from frappe.website.render import render
- return render(frappe.response['page_name'])
+ return render(frappe.response['page_name'], http_status_code=frappe.response.get("http_status_code"))
def redirect():
return werkzeug.utils.redirect(frappe.response.location)
diff --git a/frappe/utils/verified_command.py b/frappe/utils/verified_command.py
index 880a2c5e8b..8d4c30a3f4 100644
--- a/frappe/utils/verified_command.py
+++ b/frappe/utils/verified_command.py
@@ -6,15 +6,15 @@ import hmac
import urllib
import frappe
-from frappe.utils import cstr
+import frappe.utils
def get_url(cmd, params, nonce, secret=None):
signature = get_signature(params, nonce, secret)
params['signature'] = signature
- return ''.join([frappe.local.request.url_root, 'api/method/', cmd, '?', urllib.urlencode(params)])
+ return frappe.utils.get_url("".join(['api/method/', cmd, '?', urllib.urlencode(params)]))
def get_signature(params, nonce, secret=None):
- params = "".join((cstr(p) for p in params.values()))
+ params = "".join((frappe.utils.cstr(p) for p in params.values()))
if not secret:
secret = frappe.local.conf.get("secret") or "secret"
diff --git a/frappe/website/render.py b/frappe/website/render.py
index 431eabdf40..8f2aa75648 100644
--- a/frappe/website/render.py
+++ b/frappe/website/render.py
@@ -12,7 +12,7 @@ from frappe.website.permissions import get_access, clear_permissions
class PageNotFoundError(Exception): pass
-def render(path, http_status_code=200):
+def render(path, http_status_code=None):
"""render html page"""
path = resolve_path(path.lstrip("/"))
@@ -29,7 +29,7 @@ def render(path, http_status_code=200):
data = render_page(path)
http_status_code = 500
- return build_response(path, data, http_status_code)
+ return build_response(path, data, http_status_code or 200)
def build_response(path, data, http_status_code):
# build response