Ejemplo n.º 1
0
def active_trail(menu, url):
    """ Get the active menu item based on url provided, and all of its ancestors
    To be used to check each individual node's path if in this list so to obtain the active trail
    Also remove language part from url if i18n urls are enabled
    :param menu: the parent menu
    :param url: the current url to check against for the active path (should be request.path)
    :return: a recordset of all active menu ancestors
    """
    return menu.filter(path=get_clean_url(url)).get_ancestors(include_self=True) if menu else []
Ejemplo n.º 2
0
def check_path_active(node_path, request_path):
    """ Check that the two paths are equal, ignoring leading or trailing slashes
    Helper function for improving readability
    Mainly used in menu templates
    :param node_path: the menu item path
    :param request_path: the request path
    :return: boolean
    """
    url = get_clean_url(request_path)
    return node_path == url or node_path == url.strip('/')
Ejemplo n.º 3
0
def check_path_active(node_path, request_path):
    """ Check that the two paths are equal, ignoring leading or trailing slashes
    Helper function for improving readability
    Mainly used in menu templates
    :param node_path: the menu item path
    :param request_path: the request path
    :return: boolean
    """
    url = get_clean_url(request_path)
    return node_path == url or node_path == url.strip('/')
Ejemplo n.º 4
0
def active_trail(menu, url):
    """ Get the active menu item based on url provided, and all of its ancestors
    To be used to check each individual node's path if in this list so to obtain the active trail
    Also remove language part from url if i18n urls are enabled
    :param menu: the parent menu
    :param url: the current url to check against for the active path (should be request.path)
    :return: a recordset of all active menu ancestors
    """
    return menu.filter(path=get_clean_url(url)).get_ancestors(
        include_self=True) if menu else []