def _get_app_nav()

in airavata_django_portal_commons/dynamic_apps/context_processors.py [0:0]


def _get_app_nav(request, current_app):
    if hasattr(current_app, "nav"):
        # Copy and filter current_app's nav items
        nav = [
            item
            for item in copy.copy(current_app.nav)
            if "enabled" not in item or item["enabled"](request)
        ]
        # convert "/djangoapp/path/in/app" to "path/in/app"
        app_path = "/".join(request.path.split("/")[2:])
        for nav_item in nav:
            if "active_prefixes" in nav_item:
                if re.match("|".join(nav_item["active_prefixes"]), app_path):
                    nav_item["active"] = True
                else:
                    nav_item["active"] = False
            else:
                # 'active_prefixes' is optional, and if not specified, assume
                # current item is active
                nav_item["active"] = True
    else:
        # Default to the home view in the app
        nav = [
            {
                "label": current_app.verbose_name,
                "icon": "fa " + current_app.fa_icon_class,
                "url": current_app.url_home,
            }
        ]
    return nav