Ver a proveniência

feat: Role based permission for Dashboard Chart (#17634)

version-14
Shariq Ansari há 2 anos
committed by GitHub
ascendente
cometimento
4fadc21d85
Não foi encontrada uma chave conhecida para esta assinatura, na base de dados ID da chave GPG: 4AEE18F83AFDEB23
2 ficheiros alterados com 17 adições e 3 eliminações
  1. +11
    -2
      frappe/desk/doctype/dashboard_chart/dashboard_chart.json
  2. +6
    -1
      frappe/desk/doctype/dashboard_chart/dashboard_chart.py

+ 11
- 2
frappe/desk/doctype/dashboard_chart/dashboard_chart.json Ver ficheiro

@@ -42,7 +42,8 @@
"column_break_2",
"color",
"section_break_10",
"last_synced_on"
"last_synced_on",
"roles"
],
"fields": [
{
@@ -277,13 +278,20 @@
"fieldtype": "Link",
"label": "Parent Document Type",
"options": "DocType"
},
{
"fieldname": "roles",
"fieldtype": "Table",
"label": "Roles",
"options": "Has Role"
}
],
"links": [],
"modified": "2021-11-09 17:18:11.456145",
"modified": "2022-07-27 11:09:09.203236",
"modified_by": "Administrator",
"module": "Desk",
"name": "Dashboard Chart",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
@@ -323,5 +331,6 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}

+ 6
- 1
frappe/desk/doctype/dashboard_chart/dashboard_chart.py Ver ficheiro

@@ -11,7 +11,7 @@ from frappe.config import get_modules_from_all_apps_for_user
from frappe.model.document import Document
from frappe.model.naming import append_number_if_name_exists
from frappe.modules.export_file import export_to_files
from frappe.utils import cint, get_datetime, getdate, now_datetime, nowdate
from frappe.utils import cint, get_datetime, getdate, has_common, now_datetime, nowdate
from frappe.utils.dashboard import cache_source
from frappe.utils.data import format_date
from frappe.utils.dateutils import (
@@ -87,6 +87,11 @@ def has_permission(doc, ptype, user):
if doc.document_type in allowed_doctypes:
return True

if doc.roles:
allowed = [d.role for d in doc.roles]
if has_common(roles, allowed):
return True

return False




Carregando…
Cancelar
Guardar