def get_user(username): """Returns `frappe.utils.user.User` instance of given user.""" from frappe.utils.user import User if not username or username == local.session.user: return local.user else: return User(username)
def set_user(username): from frappe.utils.user import User local.session.user = username local.session.sid = username local.cache = {} local.session.data = {} local.user = User(username) local.role_permissions = {}
def get_roles(username=None): from frappe.utils.user import User if not local.session: return ["Guest"] elif not username or username == local.session.user: return local.user.get_roles() else: return User(username).get_roles()
def validate_employee_leave_approver(self): from frappe.utils.user import User from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError for l in self.get("employee_leave_approvers"): if "Leave Approver" not in User(l.leave_approver).get_roles(): throw( _("{0} is not a valid Leave Approver").format( l.leave_approver), InvalidLeaveApproverError)
def set_user(username): from frappe.utils.user import User local.session.user = username local.session.sid = username local.cache = {} local.session.data = {} local.user = User(username) local.restrictions = None local.user_perms = {}
def set_user(username): """Set current user. :param username: **User** name to set as current user.""" from frappe.utils.user import User local.session.user = username local.session.sid = username local.cache = {} local.form_dict = _dict() local.jenv = None local.session.data = _dict() local.user = User(username) local.role_permissions = {}
def get_user(username): from frappe.utils.user import User if not username or username == local.session.user: return local.user else: return User(username)
def get_user(): from frappe.utils.user import User if not local.user_obj: local.user_obj = User(local.session.user) return local.user_obj