Jump to >

reviewboard.admin.form_widgets

Admin-specific form widgets.

class RelatedObjectWidget(local_site_name=None, multivalued=True)[source]

Bases: djblets.forms.widgets.RelatedObjectWidget

A base class form widget that lets people select one or more objects.

This is a base class. Extended classes must define their own render() method, to render their own widget with their own data.

This should be used with relatedObjectSelectorView.es6.js, which extends a Backbone view to display data.

__init__(local_site_name=None, multivalued=True)[source]

Initialize the RelatedObjectWidget.

Parameters
  • local_site_name (unicode, optional) – The name of the LocalSite where the widget is being rendered.

  • multivalued (bool, optional) – Whether or not the widget should allow selecting multiple values.

class RelatedUserWidget(local_site_name=None, multivalued=True)[source]

Bases: reviewboard.admin.form_widgets.RelatedObjectWidget

A form widget to allow people to select one or more User relations.

It’s not unheard of to have a server with thousands or tens of thousands of registered users. In this case, the existing Django admin widgets fall down hard. The filtered select widgets can actually crash the webserver due to trying to pre-populate an enormous <select> element, and the raw ID widget is basically a write-only field.

This field does much better, offering both the ability to see who’s already in the list, as well as interactive search and filtering.

render(name, value, attrs=None, renderer=None)[source]

Render the widget.

Parameters
  • name (unicode) – The name of the field.

  • value (list) – The current value of the field.

  • attrs (dict, optional) – Attributes for the HTML element.

  • renderer (django.forms.renderers.BaseRenderer, optional) – The form renderer.

Returns

The rendered HTML.

Return type

django.utils.safestring.SafeText

value_from_datadict(data, files, name)[source]

Unpack the field’s value from a datadict.

Parameters
  • data (dict) – The form’s data.

  • files (dict) – The form’s files.

  • name (unicode) – The name of the field.

Returns

The list of PKs of User objects.

Return type

list

__annotations__ = {}
__slotnames__ = []
class RelatedRepositoryWidget(local_site_name=None, multivalued=True)[source]

Bases: reviewboard.admin.form_widgets.RelatedObjectWidget

A form widget allowing people to select one or more Repository objects.

This widget offers both the ability to see which repositories are already in the list, as well as interactive search and filtering.

render(name, value, attrs=None, renderer=None)[source]

Render the widget.

Parameters
  • name (unicode) – The name of the field.

  • value (list) – The current value of the field.

  • attrs (dict, optional) – Attributes for the HTML element.

  • renderer (django.forms.renderers.BaseRenderer, optional) – The form renderer.

Returns

The rendered HTML.

Return type

django.utils.safestring.SafeText

value_from_datadict(data, files, name)[source]

Unpack the field’s value from a datadict.

Parameters
  • data (dict) – The form’s data.

  • files (dict) – The form’s files.

  • name (unicode) – The name of the field.

Returns

The list of IDs of Repository objects.

Return type

list

__annotations__ = {}
__slotnames__ = []
class RelatedGroupWidget(invite_only=False, *args, **kwargs)[source]

Bases: reviewboard.admin.form_widgets.RelatedObjectWidget

A form widget allowing people to select one or more Group objects.

This widget offers both the ability to see which groups are already in the list, as well as interactive search and filtering.

__init__(invite_only=False, *args, **kwargs)[source]

Initialize the RelatedGroupWidget.

Parameters
  • invite_only (bool, optional) – Whether or not to display groups that are invite-only.

  • *args (tuple) – Positional arguments to pass to the handler.

  • **kwargs (dict) – Keyword arguments to pass to the handler.

render(name, value, attrs=None, renderer=None)[source]

Render the widget.

Parameters
  • name (unicode) – The name of the field.

  • value (list) – The current value of the field.

  • attrs (dict, optional) – Attributes for the HTML element.

  • renderer (django.forms.renderers.BaseRenderer, optional) – The form renderer.

Returns

The rendered HTML.

Return type

django.utils.safestring.SafeText

value_from_datadict(data, files, name)[source]

Unpack the field’s value from a datadict.

Parameters
  • data (dict) – The form’s data.

  • files (dict) – The form’s files.

  • name (unicode) – The name of the field.

Returns

The list of PKs of Group objects.

Return type

list

__annotations__ = {}
__slotnames__ = []
class LexersMappingWidget(attrs=None)[source]

Bases: django.forms.widgets.MultiWidget

A form widget for mapping a string to a Pygments Lexer class.

This widget displays a text input with a drop-down list of Pygments Lexer names next to it.

New in version 5.0.

__init__(attrs=None)[source]

Initialize the LexersMappingWidget.

Parameters

attrs (dict, optional) – A dictionary containing HTML attributes to be set on the rendered widget.

decompress(value)[source]

Decompress the value into a list of values for each widget.

Parameters

value (tuple of str) – The value from the field. A tuple containing two strings, a key and a Pygments Lexer name.

Returns

The list containing a key and lexer name for the widgets.

Return type

list of str

value_from_datadict(data, files, name)[source]

Unpack the field’s value from a datadict.

Parameters
  • data (dict) – The form’s data.

  • files (dict) – The form’s files.

  • name (str) – The name of the field.

Returns

The tuple containing a key and lexer name.

Return type

tuple of str

__annotations__ = {}