Merge branch 'hotfix' into fix_email_group_subscribers

This commit is contained in:
sahil28297 2019-02-08 18:33:35 +05:30 committed by GitHub
commit 5ad6131e8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 9 deletions

View file

@ -501,6 +501,7 @@ def read_only():
retval = fn(*args, **get_newargs(fn, kwargs))
if local and hasattr(local, 'master_db'):
local.db.close()
local.db = local.master_db
return retval

View file

@ -137,7 +137,7 @@ def unsubscribe(email, name):
return
primary_action = frappe.utils.get_url() + "/api/method/frappe.email.doctype.newsletter.newsletter.confirmed_unsubscribe"+\
"?" + get_signed_params({"email": email, "name":name})
"?" + get_signed_params({"email": email, "name":name.encode('utf-8')})
return_confirmation_page(email, name, primary_action)

View file

@ -212,8 +212,15 @@ def get_context(context):
please enable Allow Print For {0} in Print Settings""".format(status)),
title=_("Error in Notification"))
else:
return [{"print_format_attachment":1, "doctype":doc.doctype, "name": doc.name,
"print_format":self.print_format, "print_letterhead": print_settings.with_letterhead}]
return [{
"print_format_attachment": 1,
"doctype": doc.doctype,
"name": doc.name,
"print_format": self.print_format,
"print_letterhead": print_settings.with_letterhead,
"lang": frappe.db.get_value('Print Format', self.print_format, 'default_print_language')
if self.print_format else 'en'
}]
def get_template(self):

View file

@ -175,7 +175,8 @@ def get_email_queue(recipients, sender, subject, **kwargs):
if att.get('fid'):
_attachments.append(att)
elif att.get("print_format_attachment") == 1:
att['lang'] = frappe.local.lang
if not att.get('lang', None):
att['lang'] = frappe.local.lang
att['print_letterhead'] = kwargs.get('print_letterhead')
_attachments.append(att)
e.attachments = json.dumps(_attachments)

View file

@ -24,8 +24,10 @@ def print_has_permission_check_logs(func):
def inner(*args, **kwargs):
frappe.flags['has_permission_check_logs'] = []
result = func(*args, **kwargs)
self_perm_check = True if not kwargs['user'] else kwargs['user'] == frappe.session.user
# print only if access denied
if not result:
# and if user is checking his own permission
if not result and self_perm_check:
msgprint(('<br>').join(frappe.flags['has_permission_check_logs']))
frappe.flags.pop('has_permission_check_logs', None)
return result

View file

@ -597,7 +597,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
args: {
doctype: this.doctype,
filters: this.get_filters_for_args(),
fields: [`count(distinct ${frappe.model.get_full_column_name('name', this.doctype)}) as total_count`],
fields: [`count(${frappe.model.get_full_column_name('name', this.doctype)}) as total_count`],
}
}).then(r => {
this.total_count = r.message.values[0][0] || current_count;

View file

@ -992,7 +992,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
show_footer_message() {
const message = __('For comparison, use >5, <10 or =324. For ranges, use 5:10 (for values between 5 & 10).');
const execution_time_msg = __('Exection Time: {0} sec', [this.execution_time || 0.1]);
const execution_time_msg = __('Execution Time: {0} sec', [this.execution_time || 0.1]);
this.page.footer.removeClass('hide').addClass('text-muted col-md-12')
.html(`<span class="text-left col-md-6">${message}</span><span class="text-right col-md-6">${execution_time_msg}</span>`);

View file

@ -90,13 +90,13 @@ def download_pdf(doctype, name, format=None, doc=None, no_letterhead=0):
html = frappe.get_print(doctype, name, format, doc=doc, no_letterhead=no_letterhead)
frappe.local.response.filename = "{name}.pdf".format(name=name.replace(" ", "-").replace("/", "-"))
frappe.local.response.filecontent = get_pdf(html)
frappe.local.response.type = "download"
frappe.local.response.type = "pdf"
@frappe.whitelist()
def report_to_pdf(html, orientation="Landscape"):
frappe.local.response.filename = "report.pdf"
frappe.local.response.filecontent = get_pdf(html, {"orientation": orientation})
frappe.local.response.type = "download"
frappe.local.response.type = "pdf"
@frappe.whitelist()
def print_by_server(doctype, name, print_format=None, doc=None, no_letterhead=0):

View file

@ -42,6 +42,7 @@ def build_response(response_type=None):
'txt': as_txt,
'download': as_raw,
'json': as_json,
'pdf': as_pdf,
'page': as_page,
'redirect': redirect,
'binary': as_binary
@ -84,6 +85,13 @@ def as_json():
response.data = json.dumps(frappe.local.response, default=json_handler, separators=(',',':'))
return response
def as_pdf():
response = Response()
response.mimetype = "application/pdf"
response.headers["Content-Disposition"] = ("filename=\"%s\"" % frappe.response['filename'].replace(' ', '_')).encode("utf-8")
response.data = frappe.response['filecontent']
return response
def as_binary():
response = Response()
response.mimetype = 'application/octet-stream'