Merge pull request #9476 from scmmishra/better-only-for-message

Better Only For message
This commit is contained in:
Faris Ansari 2020-02-18 12:21:35 +05:30 committed by GitHub
commit 494c8274af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View file

@ -543,7 +543,7 @@ def only_for(roles, message=False):
myroles = set(get_roles())
if not roles.intersection(myroles):
if message:
msgprint(_('Only for {}').format(', '.join(roles)))
msgprint(_('This action is only allowed for {}').format(bold(', '.join(roles))), _('Not Permitted'))
raise PermissionError
def get_domain_data(module):

View file

@ -1022,7 +1022,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
}
get_menu_items() {
return [
let items = [
{
label: __('Refresh'),
action: () => this.refresh(),
@ -1153,6 +1153,18 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
standard: true
},
{
label: __('User Permissions'),
action: () => frappe.set_route('List', 'User Permission', {
doctype: 'Report',
name: this.report_name
}),
condition: () => frappe.model.can_set_user_permissions('Report'),
standard: true
}
];
if (frappe.user.is_report_manager()) {
items.push({
label: __('Save'),
action: () => {
let d = new frappe.ui.Dialog({
@ -1163,6 +1175,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
fieldname: 'report_name',
label: __("Report Name"),
default: this.report_doc.is_standard == 'No' ? this.report_name : "",
reqd: true
}
],
primary_action: (values) => {
@ -1184,17 +1197,10 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
d.show();
},
standard: true
},
{
label: __('User Permissions'),
action: () => frappe.set_route('List', 'User Permission', {
doctype: 'Report',
name: this.report_name
}),
condition: () => frappe.model.can_set_user_permissions('Report'),
standard: true
}
];
})
}
return items;
}
add_portrait_warning(dialog) {