コード例 #1
0
def editors_breadcrumbs(context, queue=None, addon=None, items=None,
                        themes=False):
    """
    Wrapper function for ``breadcrumbs``. Prepends 'Editor Tools'
    breadcrumbs.

    **items**
        list of [(url, label)] to be inserted after Add-on.
    **addon_queue**
        Addon object. This sets the queue by addon type or addon status.
    **queue**
        Explicit queue type to set.
    """
    crumbs = [(reverse('editors.home'), _('Editor Tools'))]
    listed = not context.get('unlisted')

    if themes:
        crumbs.append((reverse('editors.themes.home'), _('Themes')))

    if addon:
        if listed:
            queue = {amo.STATUS_NOMINATED: 'nominated',
                     amo.STATUS_PUBLIC: 'pending'}.get(addon.status, 'queue')
        else:
            queue = 'all'

    if queue:
        if listed:
            queues = {
                'queue': _('Queue'),
                'pending': _('Updates'),
                'nominated': _('New Add-ons'),
                'moderated': _('Moderated Reviews'),

                'pending_themes': _('Pending Themes'),
                'flagged_themes': _('Flagged Themes'),
                'rereview_themes': _('Update Themes'),
            }
        else:
            queues = {
                'all': _('All Unlisted Add-ons'),
            }

        if items and not queue == 'queue':
            if listed:
                url = reverse('editors.queue_{0}'.format(queue))
            else:
                # Unlisted add-ons only have the 'all' list.
                url = reverse('editors.unlisted_queue_all')
        else:
            # The Addon is the end of the trail.
            url = None
        crumbs.append((url, queues[queue]))

    if items:
        crumbs.extend(items)
    return breadcrumbs(context, crumbs, add_default=False)
コード例 #2
0
def editors_breadcrumbs(context, queue=None, addon=None, items=None,
                        themes=False):
    """
    Wrapper function for ``breadcrumbs``. Prepends 'Editor Tools'
    breadcrumbs.

    **items**
        list of [(url, label)] to be inserted after Add-on.
    **addon_queue**
        Addon object. This sets the queue by addon type or addon status.
    **queue**
        Explicit queue type to set.
    """
    crumbs = [(reverse('editors.home'), _('Editor Tools'))]
    listed = not context.get('unlisted')

    if themes:
        crumbs.append((reverse('editors.themes.home'), _('Themes')))

    if addon:
        if listed:
            queue = {amo.STATUS_NOMINATED: 'nominated',
                     amo.STATUS_PUBLIC: 'pending'}.get(addon.status, 'queue')
        else:
            queue = 'all'

    if queue:
        if listed:
            queues = {
                'queue': _('Queue'),
                'pending': _('Updates'),
                'nominated': _('New Add-ons'),
                'moderated': _('Moderated Reviews'),

                'pending_themes': _('Pending Themes'),
                'flagged_themes': _('Flagged Themes'),
                'rereview_themes': _('Update Themes'),
            }
        else:
            queues = {
                'all': _('All Unlisted Add-ons'),
            }

        if items and not queue == 'queue':
            if listed:
                url = reverse('editors.queue_{0}'.format(queue))
            else:
                # Unlisted add-ons only have the 'all' list.
                url = reverse('editors.unlisted_queue_all')
        else:
            # The Addon is the end of the trail.
            url = None
        crumbs.append((url, queues[queue]))

    if items:
        crumbs.extend(items)
    return breadcrumbs(context, crumbs, add_default=False)
コード例 #3
0
def docs_breadcrumbs(context, items=None):
    """
    Wrapper function for `breadcrumbs` for devhub docs.
    """
    crumbs = [(reverse('devhub.index'), _('Developer Hub')),
              (None, _('Developer Docs'))]

    if items:
        crumbs.extend(items)

    return breadcrumbs(context, crumbs, True)
コード例 #4
0
def docs_breadcrumbs(context, items=None):
    """
    Wrapper function for `breadcrumbs` for devhub docs.
    """
    crumbs = [(reverse('devhub.index'), _('Developer Hub')),
              (None, _('Developer Docs'))]

    if items:
        crumbs.extend(items)

    return breadcrumbs(context, crumbs, True)
コード例 #5
0
ファイル: helpers.py プロジェクト: justinpotts/addons-server
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)
コード例 #6
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)
コード例 #7
0
def editors_breadcrumbs(context,
                        queue=None,
                        addon_queue=None,
                        items=None,
                        themes=False):
    """
    Wrapper function for ``breadcrumbs``. Prepends 'Editor Tools'
    breadcrumbs.

    **items**
        list of [(url, label)] to be inserted after Add-on.
    **addon_queue**
        Addon object. This sets the queue by addon type or addon status.
    **queue**
        Explicit queue type to set.
    """
    crumbs = [(reverse('editors.home'), _('Editor Tools'))]

    if themes:
        crumbs.append((reverse('editors.themes.home'), _('Themes')))

    if addon_queue:
        queue_id = addon_queue.status
        queue_ids = {
            amo.STATUS_UNREVIEWED: 'prelim',
            amo.STATUS_NOMINATED: 'nominated',
            amo.STATUS_PUBLIC: 'pending',
            amo.STATUS_LITE: 'prelim',
            amo.STATUS_LITE_AND_NOMINATED: 'nominated',
            amo.STATUS_PENDING: 'pending'
        }

        queue = queue_ids.get(queue_id, 'queue')

    listed = not context.get('unlisted')

    if queue:
        if listed:
            queues = {
                'queue': _('Queue'),
                'pending': _('Pending Updates'),
                'nominated': _('Full Reviews'),
                'prelim': _('Preliminary Reviews'),
                'moderated': _('Moderated Reviews'),
                'fast_track': _('Fast Track'),
                'pending_themes': _('Pending Themes'),
                'flagged_themes': _('Flagged Themes'),
                'rereview_themes': _('Update Themes'),
            }
        else:
            queues = {
                'queue': _('Queue'),
                'pending': _('Unlisted Pending Updates'),
                'nominated': _('Unlisted Full Reviews'),
                'prelim': _('Unlisted Preliminary Reviews'),
                'all': _('All Unlisted Add-ons'),
            }

        if items and not queue == 'queue':
            if listed:
                url = reverse('editors.queue_{0}'.format(queue))
            else:
                url = reverse('editors.unlisted_queue_{0}'.format(queue))
        else:
            # The Addon is the end of the trail.
            url = None
        crumbs.append((url, queues[queue]))

    if items:
        crumbs.extend(items)
    return breadcrumbs(context, crumbs, add_default=False)
コード例 #8
0
ファイル: helpers.py プロジェクト: darktrojan/addons-server
def editors_breadcrumbs(context, queue=None, addon_queue=None, items=None,
                        themes=False):
    """
    Wrapper function for ``breadcrumbs``. Prepends 'Editor Tools'
    breadcrumbs.

    **items**
        list of [(url, label)] to be inserted after Add-on.
    **addon_queue**
        Addon object. This sets the queue by addon type or addon status.
    **queue**
        Explicit queue type to set.
    """
    crumbs = [(reverse('editors.home'), _('Editor Tools'))]

    if themes:
        crumbs.append((reverse('editors.themes.home'), _('Themes')))

    if addon_queue:
        queue_id = addon_queue.status
        queue_ids = {amo.STATUS_UNREVIEWED: 'prelim',
                     amo.STATUS_NOMINATED: 'nominated',
                     amo.STATUS_PUBLIC: 'pending',
                     amo.STATUS_LITE: 'prelim',
                     amo.STATUS_LITE_AND_NOMINATED: 'nominated',
                     amo.STATUS_PENDING: 'pending'}

        queue = queue_ids.get(queue_id, 'queue')

    listed = not context.get('unlisted')

    if queue:
        if listed:
            queues = {
                'queue': _('Queue'),
                'pending': _('Pending Updates'),
                'nominated': _('Full Reviews'),
                'prelim': _('Preliminary Reviews'),
                'moderated': _('Moderated Reviews'),
                'fast_track': _('Fast Track'),

                'pending_themes': _('Pending Themes'),
                'flagged_themes': _('Flagged Themes'),
                'rereview_themes': _('Update Themes'),
            }
        else:
            queues = {
                'queue': _('Queue'),
                'pending': _('Unlisted Pending Updates'),
                'nominated': _('Unlisted Full Reviews'),
                'prelim': _('Unlisted Preliminary Reviews')
            }

        if items and not queue == 'queue':
            if listed:
                url = reverse('editors.queue_{0}'.format(queue))
            else:
                url = reverse('editors.unlisted_queue_{0}'.format(queue))
        else:
            # The Addon is the end of the trail.
            url = None
        crumbs.append((url, queues[queue]))

    if items:
        crumbs.extend(items)
    return breadcrumbs(context, crumbs, add_default=False)