1
0
forked from test/crm

fix: added app permission check for apps page

This commit is contained in:
Shariq Ansari 2024-08-30 16:37:28 +05:30
parent 0edde767fd
commit 703c3c504f
2 changed files with 11 additions and 10 deletions

View File

@ -2,7 +2,6 @@ from bs4 import BeautifulSoup
import frappe
from frappe.translate import get_all_translations
from frappe.utils import cstr
from frappe.utils.telemetry import POSTHOG_HOST_FIELD, POSTHOG_PROJECT_FIELD
@frappe.whitelist(allow_guest=True)
@ -47,11 +46,13 @@ def get_user_signature():
content = f'<br><p class="signature">{signature}</p>'
return content
@frappe.whitelist()
def get_posthog_settings():
return {
"posthog_project_id": frappe.conf.get(POSTHOG_PROJECT_FIELD),
"posthog_host": frappe.conf.get(POSTHOG_HOST_FIELD),
"enable_telemetry": frappe.get_system_settings("enable_telemetry"),
"telemetry_site_age": frappe.utils.telemetry.site_age(),
}
def check_app_permission():
if frappe.session.user == "Administrator":
return True
roles = frappe.get_roles()
if any(role in ["System Manager", "Sales User", "Sales Manager", "Sales Master Manager"] for role in roles):
return True
return False

View File

@ -18,7 +18,7 @@ add_to_apps_screen = [
"logo": "/assets/crm/manifest/apple-icon-180.png",
"title": "CRM",
"route": "/crm",
# "has_permission": "crm.api.permission.has_app_permission"
"has_permission": "crm.api.check_app_permission",
}
]