Example #1
0
def dev_breadcrumbs(context,
                    addon=None,
                    items=None,
                    add_default=False,
                    impala=False):
    """
    Wrapper function for ``breadcrumbs``. Prepends 'Developer Hub'
    breadcrumbs.

    **items**
        list of [(url, label)] to be inserted after Add-on.
    **addon**
        Adds the Add-on name to the end of the trail.  If items are
        specified then the Add-on will be linked.
    **add_default**
        Prepends trail back to home when True.  Default is False.
    **impala**
        Whether to use the impala_breadcrumbs helper. Default is False.
    """
    crumbs = [(reverse('devhub.index'), _('Developer Hub'))]
    title = _('My Submissions')
    link = reverse('devhub.addons')

    if not addon and not items:
        # We are at the end of the crumb trail.
        crumbs.append((None, title))
    else:
        crumbs.append((link, title))
    if addon:
        if items:
            url = addon.get_dev_url()
        else:
            # The Addon is the end of the trail.
            url = None
        crumbs.append((url, addon.name))
    if items:
        crumbs.extend(items)

    if len(crumbs) == 1:
        crumbs = []

    if impala:
        return impala_breadcrumbs(context, crumbs, add_default)
    else:
        return breadcrumbs(context, crumbs, add_default)
Example #2
0
def dev_breadcrumbs(context, addon=None, items=None, add_default=False,
                    impala=False):
    """
    Wrapper function for ``breadcrumbs``. Prepends 'Developer Hub'
    breadcrumbs.

    **items**
        list of [(url, label)] to be inserted after Add-on.
    **addon**
        Adds the Add-on name to the end of the trail.  If items are
        specified then the Add-on will be linked.
    **add_default**
        Prepends trail back to home when True.  Default is False.
    **impala**
        Whether to use the impala_breadcrumbs helper. Default is False.
    """
    crumbs = [(reverse('devhub.index'), _('Developer Hub'))]
    title = _('My Submissions')
    link = reverse('devhub.addons')

    if not addon and not items:
        # We are at the end of the crumb trail.
        crumbs.append((None, title))
    else:
        crumbs.append((link, title))
    if addon:
        if items:
            url = addon.get_dev_url()
        else:
            # The Addon is the end of the trail.
            url = None
        crumbs.append((url, addon.name))
    if items:
        crumbs.extend(items)

    if len(crumbs) == 1:
        crumbs = []

    if impala:
        return impala_breadcrumbs(context, crumbs, add_default)
    else:
        return breadcrumbs(context, crumbs, add_default)