Jump to >

reviewboard.datagrids.sidebar

class BaseSidebarItem(sidebar, datagrid)[source]

Bases: object

Base class for an item on the sidebar of a datagrid.

Items can optionally have labels and counts associated with them. Depending on the subclass, it may also be able to nest items.

They may also have custom templates, for more advanced rendering.

See SidebarItem and BaseSidebarSection for the common types of sidebar items.

template_name = None[source]
label = None[source]
icon_name = None[source]
view_id = None[source]
view_args = None[source]
css_classes = None[source]
__init__(sidebar, datagrid)[source]

Initialize the sidebar item.

get_url()[source]

Return the URL used when clicking the item.

By default, this builds a URL to the parent datagrid using the view_id and view_args attributes. If they are not set, then the item won’t be clickable.

get_count()[source]

Return the count shown for this item.

By default, this shows nothing. Subclasses can override to display a count.

is_visible()[source]

Return whether the item is visible.

By default, an item is visible. Subclasses can override this to control visibility.

is_active()[source]

Return whether the item is currently active.

The item will be active if the current page matches the URL associated with the item.

render()[source]

Render the item.

get_extra_context()[source]

Return extra context for the render.

class BaseSidebarSection(*args, **kwargs)[source]

Bases: reviewboard.datagrids.sidebar.BaseSidebarItem

Base class for a section of items on the sidebar.

Subclasses can override this to define a section and provide items listed in the section.

Sections can optionally be clickable and display a count.

template_name = u’datagrids/sidebar_section.html’[source]
__init__(*args, **kwargs)[source]

Initialize the section.

get_items()[source]

Return the items displayed in this section.

Subclasses must override this and return or yield the items to be displayed.

is_visible()[source]

Return whether the section is visible.

By default, a section is visible if it has any item classes registered.

get_extra_context()[source]

Return extra context for the section.

class SidebarNavItem(section, label, icon_name=None, view_id=None, view_args=None, count=None, url=None, url_name=None, css_classes=None)[source]

Bases: reviewboard.datagrids.sidebar.BaseSidebarItem

A typical navigation link item on the sidebar.

This is the standard type of item added to sections on a sidebar. It will automatically generate a link to the dashboard view matching view_id and view_args, and display the provided count.

template_name = u’datagrids/sidebar_nav_item.html’[source]
__init__(section, label, icon_name=None, view_id=None, view_args=None, count=None, url=None, url_name=None, css_classes=None)[source]

Initialize the item.

get_url()[source]

Return the URL for the item.

get_count()[source]

Return the count provided in the constructor.

class Sidebar(item_classes, default_view_id=None, css_classes=[])[source]

Bases: object

Provides a sidebar for a datagrid.

A sidebar can have several item classes added to it of various types. These will be instantiated and rendered when rendering the datagrid.

__init__(item_classes, default_view_id=None, css_classes=[])[source]

Initialize the sidebar.

add_item(item_cls)[source]

Add an item class to the sidebar.

remove_item(item_cls)[source]

Remove an item class from the sidebar.

get_items(datagrid)[source]

Instantiate and returns all items on the sidebar.

class DataGridSidebarMixin[source]

Bases: object

A mixin for datagrids using a sidebar.

This is meant to be used along with Sidebar. It will initialize the sidebar, providing instances of all the items for the template.

load_extra_state(*args, **kwargs)[source]

Compute any extra state for the sidebar.