Esempio n. 1
0
File: base.py Progetto: altai/focus2
def inject_breadcrumbs():
    """Puts breadcrumbs info in template"""
    # if requested view is in blueprint
    # if requested view has breadcrumb title
    # if requested blueprint has breadcrumb title
    # return tuple of tuples enveloped in a dictionary
    try:
        view, bp = views.get_requested_view_and_blueprint()
    except TypeError:
        pass
    else:
        view_bc = breadcrumbs.get(view)
        bp_bc = breadcrumbs.get(bp)
        if view_bc is not None and bp_bc is not None:
            # second component of breadcrumb should be a link if endpoint
            # other than index is shown
            if flask.request.endpoint.endswith('.index'):
                bp_url = None
            else:
                bp_url = flask.url_for('.index')
            return {'breadcrumbs': (
                    ('Home', flask.url_for('dashboard.index')),
                    (bp_bc, bp_url),
                    (view_bc, None))}
    return {}
Esempio n. 2
0
File: base.py Progetto: altai/focus2
def inject_breadcrumb_button():
    try:
        view, _ = views.get_requested_view_and_blueprint()
    except TypeError:
        pass
    else:
        try:
            endpoint, title = breadcrumb_button.get(view)
        except TypeError:
            pass
        else:
            return {'breadcrumb_button': (flask.url_for(endpoint), title)}
    return {}