portal-dashboard/portal_dashboard/www/index.py

39 lines
1.1 KiB
Python

import frappe
def get_context(context):
host = frappe.local.request.host
base_domain = ".".join(host.split(".")[1:])
if not host.startswith("portal."):
frappe.local.flags.redirect_location = "/app"
raise frappe.Redirect
user = frappe.session.user
roles = frappe.get_roles(user)
user = frappe.session.user
roles = frappe.get_roles(user)
apps = [
{
"label": "ERP",
"icon": "fa-warehouse",
"url": "https://accounting.{base_domain}",
"roles": ["Accounts User", "Accounts Manager"]
},
{
"label": "Wiki",
"icon": "fa-book",
"url": "https://wiki.{base_domain}",
"roles": ["Employee", "System Manager"]
},
{
"label": "CRM",
"icon": "fa-user-friends",
"url": "https://crm.{base_domain}",
"roles": ["Sales User", "Sales Manager"]
}
]
context.apps = [app for app in apps if any(role in roles for role in app["roles"])]
return context