jcloude/press/utils/user.py

15 lines
463 B
Python

import jingrow
from frappe.core.doctype.user.user import User
def is_system_manager(user: str | None = None) -> bool:
"""
Checks if the given user is a system manager.
:param user: User to check. If None, uses the current session user.
:return: True if the user is a system manager, False otherwise.
"""
user = user or frappe.session.user
user_pg: User = frappe.get_cached_pg("User", user)
return bool(user_pg.get("roles", {"role": "System Manager"}))