'Check if user can access an Admin Panel'

def can_access_panel(self, panel_name):

    if self.is_staff:
        return True
    custom_sys_roles = UserSystemRole.query.filter_by(user=self)
    for custom_role in custom_sys_roles:
        if custom_role.role.can_access(panel_name):
            return True
    return False
