custom_ui/custom_ui/utils.py
2025-10-19 22:57:58 -05:00

37 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import frappe, os, json
def get_manifest():
app_path = frappe.get_app_path("custom_ui")
manifest_path = os.path.join(app_path, "custom_ui","public", "dist", ".vite", "manifest.json")
if not os.path.exists(manifest_path):
frappe.log_error(message="Manifest file not found for custom_ui", title="Manifest Load Failed")
return {}
with open(manifest_path) as f:
return json.load(f)
def create_module():
print("Creating Custom UI module if it does not exist...")
mod_name = "Custom UI"
if frappe.db.exists("Module Def", mod_name):
mod = frappe.get_doc("Module Def", mod_name)
mod.show_in_sidebar = 1 # make sure its visible
mod.save(ignore_permissions=True)
print(f"Module '{mod_name}' updated with show_in_sidebar=1")
else:
frappe.get_doc({
"doctype": "Module Def",
"module_name": mod_name,
"app_name": "custom_ui",
"color": "#1976d2",
"icon": "octicon octicon-code",
"show_in_sidebar": 1
}).insert(ignore_permissions=True)
print(f"Module '{mod_name}' created")
frappe.db.commit()
print("Custom UI module creation process completed.")
def on_login_redirect(login_manager):
frappe.local.response["type"] = "redirect"
frappe.local.response["location"] = "/app/custom-ui"