Merge branch 'develop' into fetch-from-validation
This commit is contained in:
commit
59e8564dc5
11 changed files with 80 additions and 73 deletions
|
|
@ -99,7 +99,7 @@ def application(request):
|
|||
frappe.monitor.stop(response)
|
||||
frappe.recorder.dump()
|
||||
|
||||
frappe.logger("web").info({
|
||||
frappe.logger("frappe.web").info({
|
||||
"site": get_site_name(request.host),
|
||||
"remote_addr": getattr(request, "remote_addr", "NOTFOUND"),
|
||||
"base_url": getattr(request, "base_url", "NOTFOUND"),
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@ def get_permission_query_conditions(user):
|
|||
if "System Manager" in roles:
|
||||
return None
|
||||
|
||||
allowed_doctypes = tuple(frappe.permissions.get_doctypes_with_read())
|
||||
allowed_reports = tuple([key if type(key) == str else key.encode('UTF8') for key in get_allowed_reports()])
|
||||
allowed_doctypes = ['"%s"' % doctype for doctype in frappe.permissions.get_doctypes_with_read()]
|
||||
allowed_reports = ['"%s"' % key if type(key) == str else key.encode('UTF8') for key in get_allowed_reports()]
|
||||
|
||||
return '''
|
||||
`tabDashboard Chart`.`document_type` in {allowed_doctypes}
|
||||
or `tabDashboard Chart`.`report_name` in {allowed_reports}
|
||||
`tabDashboard Chart`.`document_type` in ({allowed_doctypes})
|
||||
or `tabDashboard Chart`.`report_name` in ({allowed_reports})
|
||||
'''.format(
|
||||
allowed_doctypes=allowed_doctypes,
|
||||
allowed_reports=allowed_reports
|
||||
allowed_doctypes=','.join(allowed_doctypes),
|
||||
allowed_reports=','.join(allowed_reports)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ def get_permission_query_conditions(user=None):
|
|||
if "System Manager" in roles:
|
||||
return None
|
||||
|
||||
allowed_doctypes = tuple(frappe.permissions.get_doctypes_with_read())
|
||||
allowed_doctypes = ['"%s"' % doctype for doctype in frappe.permissions.get_doctypes_with_read()]
|
||||
|
||||
return '''
|
||||
`tabNumber Card`.`document_type` in {allowed_doctypes}
|
||||
`tabNumber Card`.`document_type` in ({allowed_doctypes})
|
||||
'''.format(
|
||||
allowed_doctypes=allowed_doctypes,
|
||||
allowed_doctypes=','.join(allowed_doctypes)
|
||||
)
|
||||
|
||||
def has_permission(doc, ptype, user):
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ def remove_from_installed_apps(app_name):
|
|||
installed_apps = frappe.get_installed_apps()
|
||||
if app_name in installed_apps:
|
||||
installed_apps.remove(app_name)
|
||||
frappe.db.set_global("installed_apps", json.dumps(installed_apps))
|
||||
frappe.db.set_value("DefaultValue", {"defkey": "installed_apps"}, "defvalue", json.dumps(installed_apps))
|
||||
frappe.db.commit()
|
||||
if frappe.flags.in_install:
|
||||
post_install()
|
||||
|
|
|
|||
|
|
@ -340,7 +340,6 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
switch_doc(docname) {
|
||||
// record switch
|
||||
if(this.docname != docname && (!this.meta.in_dialog || this.in_form) && !this.meta.istable) {
|
||||
frappe.utils.scroll_to(0);
|
||||
if (this.print_preview) {
|
||||
this.print_preview.hide();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
}
|
||||
|
||||
show() {
|
||||
this.parent.disable_scroll_to_top = true;
|
||||
|
||||
if (!this.has_permissions()) {
|
||||
frappe.set_route('');
|
||||
frappe.msgprint(__(`Not permitted to view ${this.doctype}`));
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ frappe.views.Container = Class.extend({
|
|||
|
||||
this.page._route = window.location.hash;
|
||||
$(this.page).trigger('show');
|
||||
frappe.utils.scroll_to(0);
|
||||
!this.page.disable_scroll_to_top && frappe.utils.scroll_to(0);
|
||||
frappe.breadcrumbs.update();
|
||||
|
||||
return this.page;
|
||||
|
|
|
|||
|
|
@ -8,50 +8,51 @@
|
|||
<hr>
|
||||
{% endif %}
|
||||
<table class="table table-bordered">
|
||||
<!-- heading -->
|
||||
<thead>
|
||||
<tr>
|
||||
{% for col in columns %}
|
||||
{% if col.name && col._id !== "_check" %}
|
||||
<!-- heading -->
|
||||
<thead>
|
||||
<tr>
|
||||
{% for col in columns %}
|
||||
{% if col.name && col._id !== "_check" %}
|
||||
<th
|
||||
{% if col.minWidth %}
|
||||
style="min-width: {{ col.minWidth }}px"
|
||||
{% endif %}
|
||||
{% if col.docfield && frappe.model.is_numeric_field(col.docfield) %}
|
||||
class="text-right"
|
||||
{% if col.docfield && frappe.model.is_numeric_field(col.docfield) %}
|
||||
class="text-right"
|
||||
{% endif %}
|
||||
>
|
||||
{{ __(col.name) }}</th>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- body -->
|
||||
<tbody>
|
||||
{% for row in data %}
|
||||
<tr style="height: 30px">
|
||||
{% for col in columns %}
|
||||
{% if col.name && col._id !== "_check" %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- body -->
|
||||
<tbody>
|
||||
{% for row in data %}
|
||||
<tr style="height: 30px">
|
||||
{% for col in columns %}
|
||||
{% if col.name && col._id !== "_check" %}
|
||||
|
||||
{% var value = col.fieldname ? row[col.fieldname] : row[col.id]; %}
|
||||
{% var value = col.fieldname ? row[col.fieldname] : row[col.id]; %}
|
||||
|
||||
<td {% if row.bold == 1 %} style="font-weight: bold" {% endif %}>
|
||||
<span {% if col._index == 0 %} style="padding-left: {%= cint(row.indent) * 2 %}em" {% endif %}>
|
||||
{{
|
||||
col.formatter
|
||||
? col.formatter(row._index, col._index, value, col, row, true)
|
||||
: col.format
|
||||
? col.format(value, row, col, data)
|
||||
: col.docfield
|
||||
? frappe.format(value, col.docfield)
|
||||
: value
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<td {% if row.bold == 1 %} style="font-weight: bold" {% endif %}>
|
||||
<span {% if col._index == 0 %} style="padding-left: {%= cint(row.indent) * 2 %}em" {% endif %}>
|
||||
{% format_data = row.is_total_row ? data[0] : row %}
|
||||
{{
|
||||
col.formatter
|
||||
? col.formatter(row._index, col._index, value, col, format_data, true)
|
||||
: col.format
|
||||
? col.format(value, row, col, format_data)
|
||||
: col.docfield
|
||||
? frappe.format(value, col.docfield)
|
||||
: value
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -261,27 +261,25 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
}
|
||||
|
||||
get_report_settings() {
|
||||
if (frappe.query_reports[this.report_name]) {
|
||||
this.report_settings = this.get_local_report_settings();
|
||||
return this._load_script;
|
||||
}
|
||||
|
||||
this._load_script = (new Promise(resolve => frappe.call({
|
||||
method: 'frappe.desk.query_report.get_script',
|
||||
args: { report_name: this.report_name },
|
||||
callback: resolve
|
||||
}))).then(r => {
|
||||
frappe.dom.eval(r.message.script || '');
|
||||
return r;
|
||||
}).then(r => {
|
||||
return frappe.after_ajax(() => {
|
||||
this.report_settings = this.get_local_report_settings();
|
||||
this.report_settings.html_format = r.message.html_format;
|
||||
this.report_settings.execution_time = r.message.execution_time || 0;
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
if (frappe.query_reports[this.report_name]) {
|
||||
this.report_settings = frappe.query_reports[this.report_name];
|
||||
resolve();
|
||||
} else {
|
||||
frappe.xcall('frappe.desk.query_report.get_script', {
|
||||
report_name: this.report_name
|
||||
}).then(r => {
|
||||
frappe.dom.eval(r.script || '');
|
||||
frappe.after_ajax(() => {
|
||||
this.report_settings = this.get_local_report_settings();
|
||||
this.report_settings.html_format = r.message.html_format;
|
||||
this.report_settings.execution_time = r.message.execution_time || 0;
|
||||
frappe.query_reports[this.report_name] = this.report_settings;
|
||||
resolve();
|
||||
});
|
||||
}).catch(reject);
|
||||
}
|
||||
});
|
||||
|
||||
return this._load_script;
|
||||
}
|
||||
|
||||
get_local_report_settings() {
|
||||
|
|
@ -455,6 +453,8 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
filters.prepared_report_name = query_params.prepared_report_name;
|
||||
}
|
||||
|
||||
let possible_filters = frappe.query_report[this.report_name].filters;
|
||||
|
||||
return new Promise(resolve => {
|
||||
this.last_ajax = frappe.call({
|
||||
method: 'frappe.desk.query_report.run',
|
||||
|
|
@ -1158,6 +1158,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
if (this.raw_data.add_total_row) {
|
||||
let totalRow = this.datatable.bodyRenderer.getTotalRow().reduce((row, cell) => {
|
||||
row[cell.column.id] = cell.content;
|
||||
row.is_total_row = true;
|
||||
return row;
|
||||
}, {});
|
||||
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ def render_template(template, context, is_path=None, safe_render=True):
|
|||
def guess_is_path(template):
|
||||
# template can be passed as a path or content
|
||||
# if its single line and ends with a html, then its probably a path
|
||||
if not '\n' in template and '.' in template:
|
||||
if '\n' not in template and '.' in template:
|
||||
extn = template.rsplit('.')[-1]
|
||||
if extn in ('html', 'css', 'scss', 'py'):
|
||||
if extn in ('html', 'css', 'scss', 'py', 'md', 'json', 'js', 'xml'):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
@ -109,7 +109,7 @@ def get_jloader():
|
|||
apps = frappe.local.flags.web_pages_apps or frappe.get_installed_apps(sort=True)
|
||||
apps.reverse()
|
||||
|
||||
if not "frappe" in apps:
|
||||
if "frappe" not in apps:
|
||||
apps.append('frappe')
|
||||
|
||||
frappe.local.jloader = ChoiceLoader(
|
||||
|
|
|
|||
|
|
@ -300,7 +300,11 @@ def setup_source(page_info):
|
|||
css = f.read()
|
||||
html += '\n{% block style %}\n<style>\n' + css + '\n</style>\n{% endblock %}'
|
||||
|
||||
page_info.source = html
|
||||
if html:
|
||||
page_info.source = html
|
||||
page_info.base_template = page_info.base_template or 'templates/web.html'
|
||||
else:
|
||||
page_info.source = ''
|
||||
|
||||
# show table of contents
|
||||
setup_index(page_info)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue