diff --git a/crm/api/__init__.py b/crm/api/__init__.py index f0909118..9b282a45 100644 --- a/crm/api/__init__.py +++ b/crm/api/__init__.py @@ -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'

{signature}

' 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(), - } \ No newline at end of file + +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 \ No newline at end of file diff --git a/crm/hooks.py b/crm/hooks.py index ce6f23e8..e53fc8aa 100644 --- a/crm/hooks.py +++ b/crm/hooks.py @@ -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", } ]