def navtree(request): """adds the variable 'navtree' to the context: [ { 'name': 'about', 'title': 'All about the site', 'url': '/about/', 'children': [] }, { 'name': 'news', 'title': 'Latest News', 'url': '/news/', 'children': [ { 'name': 'August', 'title': 'August Archive', 'url': '/news/aug/', 'children': [] }, ]] """ navbar = get_navtree(request.user, MAX_DEPTH) if MARK_SELECTED: _mark_selected(request.path, navbar['byurl']) return {'navtree': navbar['tree']}
def navbars(request): """adds the variable 'navbars' to the context" """ nav = get_navtree(request.user, MAX_DEPTH) navbar = nav['tree'] _mark_selected(request.path, nav['byurl']) navbars = [ navbar ] found = True while navbar and found: found = False for ent in navbar: if ent['selected']: navbar = ent['children'] if navbar: navbars.append(navbar) found = True break; if SHOW_DEPTH > len(navbars): navbars += [[]]*(SHOW_DEPTH - len(navbars)) return { 'navbars': navbars }
def navbars(request): """adds the variable 'navbars' to the context" """ nav = get_navtree(request.user, MAX_DEPTH) navbar = nav['tree'] _mark_selected(request.path, nav['byurl']) navbars = [navbar] found = True while navbar and found: found = False for ent in navbar: if ent['selected']: navbar = ent['children'] if navbar: navbars.append(navbar) found = True break if SHOW_DEPTH > len(navbars): navbars += [[]] * (SHOW_DEPTH - len(navbars)) return {'navbars': navbars}