diff --git a/frappe/__init__.py b/frappe/__init__.py index a83bd48042..12f1157196 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -94,6 +94,7 @@ def init(site, sites_path=None): local.site_path = os.path.join(sites_path, site) local.request_method = request.method if request else None + local.request_ip = None local.response = _dict({"docs":[]}) local.conf = _dict(get_site_config()) diff --git a/frappe/auth.py b/frappe/auth.py index 0597e7d59e..3dc06bcd39 100644 --- a/frappe/auth.py +++ b/frappe/auth.py @@ -20,6 +20,8 @@ class HTTPRequest: if self.domain and self.domain.startswith('www.'): self.domain = self.domain[4:] + frappe.local.request_ip = frappe.get_request_header('REMOTE_ADDR') \ + or frappe.get_request_header('X-Forwarded-For') or '127.0.0.1' # language self.set_lang(frappe.get_request_header('HTTP_ACCEPT_LANGUAGE')) @@ -157,7 +159,7 @@ class LoginManager: ip_list = [i.strip() for i in ip_list] for ip in ip_list: - if frappe.get_request_header('REMOTE_ADDR', '').startswith(ip) or frappe.get_request_header('X-Forwarded-For', '').startswith(ip): + if frappe.local.request_ip.startswith(ip): return frappe.throw(_("Not allowed from this IP Address"), frappe.AuthenticationError) diff --git a/frappe/public/js/legacy/form.js b/frappe/public/js/legacy/form.js index 2c8fe68402..5b60d8070d 100644 --- a/frappe/public/js/legacy/form.js +++ b/frappe/public/js/legacy/form.js @@ -129,7 +129,8 @@ _f.Frm.prototype.setup_print_layout = function() {
\ Letterhead
\
\ - Print\ + Preview\ + Print\ ×\
\ \ @@ -156,13 +157,22 @@ _f.Frm.prototype.setup_print_layout = function() { }, !me.print_letterhead.is(":checked"), true, true); }) - this.print_wrapper.find(".print-print").click(function() { + this.print_wrapper.find(".btn-print-print").click(function() { _p.build( me.print_sel.val(), // fmtname _p.go, // onload !me.print_letterhead.is(":checked") // no_letterhead ); - }) + }); + + this.print_wrapper.find(".btn-print-preview").click(function() { + _p.build( + me.print_sel.val(), // fmtname + _p.preview, // onload + !me.print_letterhead.is(":checked") // no_letterhead + ); + }); + } _f.Frm.prototype.print_doc = function() { diff --git a/frappe/public/js/legacy/print_format.js b/frappe/public/js/legacy/print_format.js index 82a29f02f6..ce891a2141 100644 --- a/frappe/public/js/legacy/print_format.js +++ b/frappe/public/js/legacy/print_format.js @@ -38,6 +38,7 @@ _p.preview = function(html) { return; } w.document.write(html); + w.document.close(); return w } diff --git a/frappe/templates/includes/sidebar.html b/frappe/templates/includes/sidebar.html index a3fb30e8e8..12a8b6a8f6 100644 --- a/frappe/templates/includes/sidebar.html +++ b/frappe/templates/includes/sidebar.html @@ -7,7 +7,7 @@ {% if (child.lft != None) and (child.rgt - child.lft != 1) and (not loop.first) %}icon-chevron-right{% endif %}" style="margin-left: -15px; color: #ddd; {% if is_parent %}margin-left: -30px;{% endif %}"> - {{ child.page_title }} + {{ child.page_title or child.name.replace("_", " ").title() }} {% if not child.public_read %} () {% endif %}