Jump to >

reviewboard.admin.widgets

class BaseAdminWidget[source]

Bases: object

The base class for an Administration Dashboard widget.

Widgets appear in the Administration Dashboard and can display useful information on the system, links to other pages, or even fetch data from external sites.

There are a number of built-in widgets, but extensions can provide their own.

Version Added::

4.0: Introduced a a replacement for the legacy Widget class.

widget_id = None[source]

The unique ID of the widget.

name = None[source]

The name of the widget.

This will be shown at the top of the widget.

template_name = 'admin/admin_widget.html'[source]

The name of the template used to render the widget.

css_classes = None[source]

Additional CSS classes to apply to the widget.

If set, this must be a string with a space-separated list of CSS classes.

js_view_class = 'RB.Admin.WidgetView'[source]

The name of the JavaScript view rendering the widget.

js_model_class = 'RB.Admin.Widget'[source]

The name of the JavaScript model handling widget state.

__init__()[source]

Initialize the widget.

can_render(request)[source]

Return whether the widget can be rendered in the dashboard.

Subclasses can override this to make certain widgets conditional. By default, widgets can always be rendered.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

True, always.

Return type

bool

get_js_model_attrs(request)[source]

Return attributes to pass to the JavaScript model.

These attributes will be passed to the widget model when instantiated.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

The attributes to pass to the model.

Return type

dict

get_js_model_options(request)[source]

Return options to pass to the JavaScript model.

These options will be passed to the widget model when instantiated.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

The options to pass to the model.

Return type

dict

get_js_view_options(request)[source]

Return options to pass to the JavaScript view.

These options will be passed to the widget view when instantiated.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

The options to pass to the view.

Return type

dict

get_extra_context(request)[source]

Return extra context for the template.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

Extra context to pass to the template.

Return type

dict

render(request)[source]

Render the widget to a string.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

The rendered widget HTML.

Return type

django.utils.safestring.SafeText

class AdminWidgetsRegistry[source]

Bases: djblets.registries.registry.OrderedRegistry

The registry managing all administration dashboard widgets.

lookup_attrs = ('widget_id',)[source]

A list of attributes that items can be looked up by.

default_errors = {'already_registered': 'Could not register the administration widget %(item)s. This widget is already registered or its ID conflicts with another widget.', 'attribute_registered': 'Could not register the administration widget %(item)s: Another widget (%(duplicate)s) is already registered with the same ID.', 'invalid_attribute': '"%(attr_name)s" is not a registered lookup attribute.', 'load_entry_point': 'Could not load entry point %(entry_point)s: %(error)s.', 'missing_attribute': 'Could not register %(item)s: it does not have a "%(attr_name)s" attribute.', 'not_registered': 'No administration widget was found with an ID of "%(attr_value)s".', 'unregister': 'Could not unregister the administration widget %(item)s: This widget has not been registered.'}[source]

The default error formatting strings.

If subclasses need to provide additional errors that can be overridden, they should copy DEFAULT_ERRORS and set their copy on the subclass as this attribute.

register(**kwargs)[source]

Register a new administration widget class.

Parameters

admin_widget_cls (type) – The widget class to register. This must be a subclass of BaseAdminWidget.

Raises
unregister(**kwargs)[source]

Unregister an administration widget class.

Parameters

admin_widget_cls (type) – The widget class to unregister. This must be a subclass of BaseAdminWidget.

Raises

djblets.registries.errors.ItemLookupError – This widget was not registered.

get_widget(widget_id)[source]

Return a widget class with the specified ID.

Parameters

widget_id (unicode) – The ID of the widget to return.

Returns

The subclass of BaseAdminWidget that was registered with the given ID, if found. If the widget was not found, this will return None.

Return type

type

get_defaults()[source]

Return the default widgets for the administration dashboard.

Returns

The list of default widgets.

Return type

list of type

__annotations__ = {}
get_sync_num()[source]

Get the sync_num, which is number to sync.

sync_num is number of update and initialized to 1 every day.

class UserActivityWidget[source]

Bases: reviewboard.admin.widgets.BaseAdminWidget

A widget displaying stats on how often users interact with Review Board.

This is displayed as a pie graph, with a legend alongside it breaking down the activity into 1-6 day, 7-29 day, 30-59 day, 60-89 day, and 90+ day ranges.

widget_id = 'user-activity-widget'[source]

The unique ID of the widget.

name = 'User Activity'[source]

The name of the widget.

This will be shown at the top of the widget.

js_view_class = 'RB.Admin.UserActivityWidgetView'[source]

The name of the JavaScript view rendering the widget.

css_classes = 'rb-c-admin-user-activity-widget'[source]

Additional CSS classes to apply to the widget.

If set, this must be a string with a space-separated list of CSS classes.

get_js_model_attrs(request)[source]

Return data for the JavaScript model.

This will calculate the user activity in the various time ranges, and return the data for use in a rendered chart.

Parameters

request (django.http.HttpRequest, unused) – The HTTP request from the client.

Returns

Data for the JavaScript model,.

Return type

dict

__annotations__ = {}
class RepositoriesWidget[source]

Bases: reviewboard.admin.widgets.BaseAdminWidget

A widget displaying the most recent repositories.

This widget displays a grid of the most recent repositories and their services/types.

MAX_REPOSITORIES = 8[source]

The maximum number of repositories shown in the widget.

widget_id = 'repositories-widget'[source]

The unique ID of the widget.

name = 'Repositories'[source]

The name of the widget.

This will be shown at the top of the widget.

css_classes = 'rb-c-admin-repositories-widget'[source]

Additional CSS classes to apply to the widget.

If set, this must be a string with a space-separated list of CSS classes.

template_name = 'admin/widgets/repositories.html'[source]

The name of the template used to render the widget.

get_extra_context(request)[source]

Return extra context for the template.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

Extra context to pass to the template.

Return type

dict

__annotations__ = {}
class ServerCacheWidget[source]

Bases: reviewboard.admin.widgets.BaseAdminWidget

Cache statistics widget.

Displays a list of memcached statistics, if available.

widget_id = 'server-cache-widget'[source]

The unique ID of the widget.

name = 'Server Cache'[source]

The name of the widget.

This will be shown at the top of the widget.

template_name = 'admin/widgets/server_cache.html'[source]

The name of the template used to render the widget.

get_extra_context(request)[source]

Return extra context for the template.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

Extra context to pass to the template.

Return type

dict

__annotations__ = {}
class NewsWidget[source]

Bases: reviewboard.admin.widgets.BaseAdminWidget

A widget displaying the latest Review Board news headlines.

widget_id = 'news'[source]

The unique ID of the widget.

name = 'Review Board News'[source]

The name of the widget.

This will be shown at the top of the widget.

css_classes = 'rb-c-admin-news-widget'[source]

Additional CSS classes to apply to the widget.

If set, this must be a string with a space-separated list of CSS classes.

js_view_class = 'RB.Admin.NewsWidgetView'[source]

The name of the JavaScript view rendering the widget.

js_model_class = 'RB.Admin.NewsWidget'[source]

The name of the JavaScript model handling widget state.

get_js_model_attrs(request)[source]

Return attributes to pass to the JavaScript model.

These contain URLs for the RSS feed and the public news page.

Parameters

request (django.http.HttpRequest) – The HTTP request from the client.

Returns

The attributes to pass to the model.

Return type

dict

__annotations__ = {}
dynamic_activity_data(request)[source]

Large database activity widget helper.

This method serves as a helper for the activity widget, it’s used with for AJAX requests based on date ranges passed to it.

class ActivityGraphWidget[source]

Bases: reviewboard.admin.widgets.BaseAdminWidget

Detailed database statistics graph widget.

Shows the latest database activity for multiple models in the form of a graph that can be navigated by date.

This widget shows a daily view of creation activity for a list of models. All displayed widget data is computed on demand, rather than up-front during creation of the widget.

widget_id = 'activity-graph-widget'[source]

The unique ID of the widget.

name = 'Review Board Activity'[source]

The name of the widget.

This will be shown at the top of the widget.

js_model_class = 'RB.Admin.ServerActivityWidget'[source]

The name of the JavaScript model handling widget state.

js_view_class = 'RB.Admin.ServerActivityWidgetView'[source]

The name of the JavaScript view rendering the widget.

css_classes = 'rb-c-admin-server-activity-widget'[source]

Additional CSS classes to apply to the widget.

If set, this must be a string with a space-separated list of CSS classes.

__annotations__ = {}
init_widgets()[source]

Initialize the widgets subsystem.

This will listen for events in order to manage the widget caches.

register_admin_widget(widget_cls, primary=False)[source]

Register an administration widget.

Deprecated::

4.0: Widgets should be registered on admin_widgets_registry instead.

Parameters
unregister_admin_widget(widget_cls)[source]

Unregister a previously registered administration widget.

admin_widgets_registry = <reviewboard.admin.widgets.AdminWidgetsRegistry object>[source]

The registry of available administration widgets.