reviewboard.reviews.fields¶
Definitions for review request fields.
- TFieldValue[source]¶
Generic type for a field’s value.
New in version 7.1.
alias of TypeVar(‘TFieldValue’, bound=
Any)
- class ReviewRequestFieldChangeEntrySection[source]¶
Bases:
TypedDictA rendered section in a Change Description.
This is returned by
BaseReviewRequestField. get_change_entry_sections_html()in order to populate the change history of a review request.Each section can have a title/label and the HTML of the changed content.
New in version 7.1.
- rendered_html: SafeString¶
The rendered HTML showing the changes.
- title: StrOrPromise¶
The title of the section.
- __closed__ = None¶
- __extra_items__ = typing_extensions.NoExtraItems¶
- __mutable_keys__ = frozenset({'rendered_html', 'title'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'rendered_html', 'title'})¶
- __total__ = True¶
- class FieldSetRegistry[source]¶
Bases:
OrderedRegistry[Type[BaseReviewRequestFieldSet]]A registry for field sets.
This keeps the fieldsets in the registered order, so iterating through them will do so in the same order.
- lookup_attrs: Sequence[str] = ('fieldset_id',)[source]¶
A list of attributes that items can be looked up by.
- errors: RegistryErrorsDict = {'already_registered': '"%(item)s" is already a registered review request fieldset.', 'not_registered': '%(attr_value)s is not a registered review request fieldset.'}[source]¶
Error formatting strings for exceptions.
Entries here override the global
DEFAULT_ERRORSdictionary for error messages.- Type:
- register(fieldset: type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]) None[source]¶
Register the fieldset.
This will also register all field classes registered on the fieldset on the field registry.
- Parameters:
fieldset (
type) – The fieldset to register, as aBaseReviewRequestFieldSetsubclass.
- unregister(fieldset: type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]) None[source]¶
Unregister the fieldset.
This will unregister all field classes on the fieldset from the field registry.
- Parameters:
fieldset (
type) – The field to remove, as aBaseReviewRequestFieldSetsubclass.
- get_defaults() Iterable[type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]][source]¶
Return the list of built-in fieldsets.
- Returns:
A list of the built-in
BaseReviewRequestFieldSetsubclasses.- Return type:
- class FieldRegistry[source]¶
Bases:
Registry[Type[BaseReviewRequestField]]A registry for review request fields.
- lookup_attrs: Sequence[str] = ['field_id'][source]¶
A list of attributes that items can be looked up by.
- errors: RegistryErrorsDict = {'already_registered': '"%(item)s" is already a registered review request field. Field IDs must be unique across all fieldsets.', 'not_registered': '"%(attr_value)s is not a registered review request fieldset.'}[source]¶
Error formatting strings for exceptions.
Entries here override the global
DEFAULT_ERRORSdictionary for error messages.- Type:
- class BaseReviewRequestFieldSet(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
objectBase class for sets of review request fields.
A fieldset stores a list of fields that are rendered on the review request page. They may contain default fields, and new fields can be added or removed.
Review Board provides three main fieldsets: “main”, “info”, and “reviewers”. Others can be added by subclassing and registering through
fieldset_registry.Changed in version 4.0.7: Subclasses can now dynamically instantiate fields without registering their classes by overriding
build_fields().- fieldset_id: Optional[str] = None¶
The ID of the fieldset.
This must be unique within the
field_registry.- Type:
- show_required: bool = False¶
Whether to show this fieldset as required.
If set, the fieldset will show as required if the user is able to modify the review request.
- Type:
- field_classes: Optional[list[type[BaseReviewRequestField]]] = None¶
A list of fields that will by default be instantiated for the fieldset.
These would be set by subclasses to a list of
BaseReviewRequestFieldsubclasses.- Type:
- __init__(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None) None[source]¶
Initialize the field set.
- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request or draft.request (
django.http.HttpRequest, optional) –The HTTP request that resulted in building this fieldset.
New in version 4.0.7.
- review_request_details: BaseReviewRequestDetails¶
The review request details that this field will operate on.
- request: Optional[HttpRequest]¶
The HTTP request from the client.
- classmethod is_empty() bool[source]¶
Return whether the fieldset is empty.
A fieldset is empty if there are no field classes registered. An empty fieldset will not be displayed on the page.
- classmethod add_field(field_cls: type[reviewboard.reviews.fields.BaseReviewRequestField]) None[source]¶
Add a field class to this fieldset.
The field will be rendered inside this fieldset on the page.
A given field class can only be in one fieldset. Its
field_idmust be unique.- Parameters:
field_cls (
class) – The field class to add.
- classmethod remove_field(field_cls: type[reviewboard.reviews.fields.BaseReviewRequestField]) None[source]¶
Remove a field class from this fieldset.
The field class must have been previously added to this fieldset.
- Parameters:
field_cls (
class) – The field class to remove.
- should_render[source]¶
Whether the fieldset should render.
By default, fieldsets should render if any contained fields should render. Subclasses can override this if they need different behavior.
New in version 4.0.7.
- Type:
- fields[source]¶
A list of all field instances in this fieldset.
Fields are instantiated through
build_fields()the first time this is accessed.New in version 4.0.7.
- Type:
- build_fields() Sequence[BaseReviewRequestField][source]¶
Return new fields for use in this fieldset instance.
By default, this will loop through
field_classesand instantiate each field, returning the final list.Subclasses can override this to provide custom logic, including returning field instances that aren’t registered as field classes. This can be used to build fields tailored to a particular review request.
New in version 4.0.7.
- Returns:
The list of new field instances.
- Return type:
- class BaseReviewRequestField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
Generic[TFieldValue]Base class for a field on a review request.
A field is responsible for displaying data from a review request, handling any editing requirements if necessary, recording changes in the ChangeDescription, and rendering those changes.
Each field must have its own unique
field_id. This ID will be used when looking up or storing the field’s value.It is recommended that fields provided by extensions prefix their field ID with some sort of identifier for the extension or the vendor.
Creating a new field requires subclassing BaseReviewRequestField and overriding any fields or functions necessary. Its class must then be added to a fieldset.
A field will be instantiated with either a ReviewRequest or a ReviewRequestDraft, depending on what is being edited. This is stored in
review_request_details. Functions should optimistically fetch values from that, if possible. They can callget_review_request()onreview_request_detailsto fetch the actual ReviewRequest.If the function takes a
review_request_detailsparameter, it must use that instead.- label: Optional[StrOrPromise] = None¶
The visible label for the field.
- change_entry_renders_inline: bool = True¶
Whether change entries for this field should render inline.
These will be presented in a more compact format. This should be disabled for longer fields, such as those containing multi-line text or other contents.
- model: Optional[type[Model]] = None¶
An optional database model that backs this field.
If set, this field will track changes made to instances of this model.
- js_view_class: Optional[str] = None¶
The class name for the JavaScript view representing this field.
- __init__(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None) None[source]¶
Initialize the field.
- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request or draft.request (
django.http.HttpRequest, optional) – The current HTTP request (used to check display preferences for the logged-in user).
- review_request_details: BaseReviewRequestDetails¶
The review request details that this field will operate on.
- request: Optional[HttpRequest]¶
The HTTP request from the client.
- property value: Optional[TFieldValue][source]¶
Return the value loaded from the database.
This will fetch the value with the associated ReviewRequest or ReviewRequestDraft, and then cache it for future lookups.
- Returns:
The value of the field.
- Return type:
- has_value_changed(old_value: TFieldValue, new_value: TFieldValue) bool[source]¶
Return whether the value has changed.
By default, it performs an inequality check on the values. This can be overridden to perform more specialized checks.
- record_change_entry(changedesc: ChangeDescription, old_value: TFieldValue, new_value: TFieldValue) None[source]¶
Record information on the changed values in a ChangeDescription.
By default, the values are stored as-is along with the field ID. This can be overridden to perform more specialized storage.
- Parameters:
changedesc (
reviewboard.changedescs.models.ChangeDescription) – The change description to record the entry in.old_value (
object) – The old value of the field.new_value (
object) – The new value of the field.
- serialize_change_entry(changedesc: ChangeDescription) Union[WebAPIResponsePayload, Sequence[WebAPIResponsePayload]][source]¶
Serialize a change entry for public consumption.
This will output a version of the change entry for use in the API. It can be the same content stored in the
ChangeDescription, but does not need to be.- Parameters:
changedesc (
reviewboard.changedescs.models.ChangeDescription) – The change description whose field is to be serialized.- Returns:
An appropriate serialization for the field.
- Return type:
- serialize_change_entry_for_model_list(field_info: Any) Union[WebAPIResponsePayload, Sequence[WebAPIResponsePayload]][source]¶
Return the change entry for a list of models.
- serialize_change_entry_for_singleton(field_info: Any) Union[WebAPIResponsePayload, Sequence[WebAPIResponsePayload]][source]¶
Return the change entry for a singleton.
Singleton fields (e.g., summaries) are stored in
ChangeDescriptionas a list with a single element.
- serialize_change_entry_for_list(field_info: Any) Union[WebAPIResponsePayload, Sequence[WebAPIResponsePayload]][source]¶
Return the change entry for a list of plain data.
- get_change_entry_sections_html(info: Any) Sequence[ReviewRequestFieldChangeEntrySection][source]¶
Return sections of change entries with titles and rendered HTML.
By default, this just returns a single section for the field, with the field’s title and rendered change HTML.
Subclasses can override this to provide more information.
- render_change_entry_html(info: Any) SafeString[source]¶
Render a change entry to HTML.
By default, this returns a simple “changed from X to Y” using the old and new values. This can be overridden to generate more specialized output.
This function is expected to return safe, valid HTML. Any values coming from a field or any other form of user input must be properly escaped.
Subclasses can override
render_change_entry_value_html()to change how the value itself will be rendered in the string.Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
info (
dict) –A dictionary describing how the field has changed.
For standard field changes, this is guaranteed to have
newandoldkeys, but may also containaddedandremovedkeys as well.Subclasses may store and render data in custom formats.
- Returns:
The HTML representation of the change entry.
- Return type:
- render_change_entry_added_value_html(info: Any, value: Any) SafeString[source]¶
Render the change entry for an added value to HTML.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- render_change_entry_removed_value_html(info: Any, value: Any) SafeString[source]¶
Render the change entry for a removed value to HTML.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- render_change_entry_value_html(info: Any, value: Any) SafeString[source]¶
Render the value for a change description string to HTML.
By default, this just converts the value to text and escapes it. This can be overridden to customize how the value is displayed.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- load_value(review_request_details: BaseReviewRequestDetails) Optional[TFieldValue][source]¶
Load a value from the review request or draft.
By default, this loads the value as-is from the extra_data field. This can be overridden if you need to deserialize the value in some way.
This must use
review_request_detailsinstead ofself.review_request_details.- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request or draft.
- save_value(value: Optional[TFieldValue]) None[source]¶
Save the value in the review request or draft.
By default, this saves the value as-is in the extra_data field. This can be overridden if you need to serialize the value in some way.
- Parameters:
value (
object) – The new value for the field.
- propagate_data(review_request_details: BaseReviewRequestDetails) None[source]¶
Propagate data in from source review request or draft.
By default, this loads only the field’s value from a source review request or draft and saves it as-is into the review request or draft associated with the field. This can be overridden if you need to propagate additional data elements.
This method is preferable to explicitly calling
load_value()andsave_value()in series to propagate data from a source into a field, because it allows for copying additional data elements beyond only the field’s value.This function must use the
review_request_detailsparameter instead of thereview_request_detailsattribute on the field.- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The source review request or draft whose data is to be propagated.
- render_value(value: Optional[TFieldValue]) SafeString[source]¶
Render the value in the field.
By default, this converts to text and escapes it. This can be overridden if you need to render it in a more specific way.
This must use
valueinstead ofself.value.Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
value (
object) – The value to render.- Returns:
The rendered value.
- Return type:
- get_css_classes() set[str][source]¶
Return the set of CSS classes to apply to the element.
By default, this will include the contents of
default_css_classes, and"required"if it’s a required field.This can be overridden to provide additional CSS classes, if they’re not appropriate for :py:attr:default_css_classes`.
- get_dom_attributes() dict[str, str][source]¶
Return any additional attributes to include in the element.
By default, this returns nothing.
- Returns:
Additional key/value pairs for attributes to include in the rendered HTML element.
- Return type:
- get_data_attributes() dict[str, Any][source]¶
Return any data attributes to include in the element.
By default, this returns nothing.
- Returns:
The data attributes to include in the element.
- Return type:
- as_html() SafeString[source]¶
Return the field rendered to HTML.
- Returns:
The rendered field.
- Return type:
django.utils.safetext.SafeString
- value_as_html() SafeString[source]¶
Return the field rendered as HTML.
By default, this just calls
render_valuewith the value from the database.Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Returns:
The rendered field.
- Return type:
- class BaseEditableField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
BaseReviewRequestField[TFieldValue]Base class for an editable field.
This simply marks the field as editable.
- class BaseCommaEditableField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
BaseEditableField[Sequence[TFieldValue]]Base class for an editable comma-separated list of values.
This is used for dealing with lists of items that appear comma-separated in the UI. It works with stored lists of content on the review request or draft, and on the ChangeDescription.
Subclasses can override this to provide specialized rendering on a per-item-basis. That’s useful for showing links to items, for example.
- default_css_classes: Sequence[str] = ['editable', 'comma-editable'][source]¶
The default CSS classes to use on this field.
- order_matters = False[source]¶
Whether order matters for the items.
If order matters, that order will be preserved. Otherwise, it may be changed when editing.
- js_view_class: Optional[str] = 'RB.ReviewRequestFields.CommaSeparatedValuesTextFieldView'[source]¶
The class name for the JavaScript view representing this field.
- has_value_changed(old_value: Sequence[TFieldValue], new_value: Sequence[TFieldValue]) bool[source]¶
Return whether two values have changed.
If
order_mattersis set toTrue, this will do a strict list comparison. Otherwise, it will compare the items in both lists without caring about the ordering.
- serialize_change_entry(changedesc: ChangeDescription) SerializableDjangoJSONDict[source]¶
Serialize a change entry for public consumption.
This will output a version of the change entry for use in the API. It can be the same content stored in the
ChangeDescription, but does not need to be.- Parameters:
changedesc (
reviewboard.changedescs.models.ChangeDescription) – The change description whose field is to be serialized.- Returns:
An appropriate serialization for the field.
- Return type:
- render_value(value: Optional[Sequence[TFieldValue]]) SafeString[source]¶
Render the list of items.
This will call out to
render_itemfor every item. The list of rendered items will be separated by a comma and a space.Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
value (
object) – The value to render.- Returns:
The rendered value.
- Return type:
- render_item(item: TFieldValue) SafeString[source]¶
Render an item from the list.
By default, this will convert the item to text and then escape it.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
item (
object) – The item to render.- Returns:
The rendered item.
- Return type:
- render_change_entry_html(info: Any) SafeString[source]¶
Render a change entry to HTML.
By default, this returns HTML containing a list of removed items, and a list of added items. This can be overridden to generate more specialized output.
This function is expected to return safe, valid HTML. Any values coming from a field or any other form of user input must be properly escaped.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
info (
dict) – A dictionary describing how the field has changed. This is guaranteed to havenewandoldkeys, but may also containaddedandremovedkeys as well.- Returns:
The HTML representation of the change entry.
- Return type:
- render_change_entry_value_html(info: Any, value: Sequence[Any]) SafeString[source]¶
Render a list of items for change description HTML.
By default, this will call
render_change_entry_item_htmlfor every item in the list. The list of rendered items will be separated by a comma and a space.Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- render_change_entry_item_html(info: Any, item: Any) SafeString[source]¶
Render an item for change description HTML.
By default, this just converts the value to text and escapes it. This can be overridden to customize how the value is displayed.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- class BaseTextAreaField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
BaseEditableField[str]Base class for a multi-line text area field.
The text area can take either plain text or Markdown text. By default, Markdown is supported, but this can be changed by setting
enable_markdowntoFalse.- default_css_classes: Sequence[str] = ['editable', 'field-text-area'][source]¶
The default CSS classes to use on this field.
- js_view_class: Optional[str] = 'RB.ReviewRequestFields.MultilineTextFieldView'[source]¶
The class name for the JavaScript view representing this field.
- text_type_key[source]¶
Return the text type key for the
extra_datadictionary.- Returns:
The key which stores the text type for the field.
- Return type:
- is_text_markdown(value: Optional[str]) bool[source]¶
Return whether the text is in Markdown format.
This can be overridden if the field needs to check something else to determine if the text is in Markdown format.
- propagate_data(review_request_details: BaseReviewRequestDetails) None[source]¶
Propagate data in from source review request or draft.
In addition to the value propagation handled by the base class, this copies the text type details from a source review request or draft and saves it as-is into the review request or draft associated with the field.
- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The source review request or draft whose data is to be propagated.
- get_css_classes() set[str][source]¶
Return the list of CSS classes.
If Markdown is enabled, and the text is in Markdown format, this will add a “rich-text” field.
- get_data_attributes() dict[str, Any][source]¶
Return any data attributes to include in the element.
By default, this returns nothing.
- Returns:
The data attributes to include in the element.
- Return type:
- render_value(value: Optional[str]) SafeString[source]¶
Return the value of the field.
If Markdown is enabled, and the text is not in Markdown format, the text will be escaped.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
value (
str) – The value of the field.- Returns:
The rendered value.
- Return type:
- should_render_as_markdown(value: Optional[str]) bool[source]¶
Return whether the text should be rendered as Markdown.
By default, this checks if the field is set to always render any text as Markdown, or if the given text is in Markdown format.
- render_change_entry_html(info: Any) SafeString[source]¶
Render a change entry to HTML.
This will render a diff of the changed text.
This function is expected to return safe, valid HTML. Any values coming from a field or any other form of user input must be properly escaped.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
info (
dict) – A dictionary describing how the field has changed. This is guaranteed to havenewandoldkeys, but may also containaddedandremovedkeys as well.- Returns:
The HTML representation of the change entry.
- Return type:
- class BaseCheckboxField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
BaseReviewRequestField[bool]Base class for a checkbox.
The field’s value will be either True or False.
- js_view_class: Optional[str] = 'RB.ReviewRequestFields.CheckboxFieldView'[source]¶
The class name for the JavaScript view representing this field.
- default_value: bool = False¶
The default value of the field.
This can be set by subclasses to override the default checkbox state.
- load_value(review_request_details: BaseReviewRequestDetails) bool[source]¶
Load a value from the review request or draft.
- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request or draft.- Returns:
The loaded value.
- Return type:
- render_change_entry_html(info: Any) SafeString[source]¶
Render a change entry to HTML.
This function is expected to return safe, valid HTML. Any values coming from a field or any other form of user input must be properly escaped.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
info (
dict) – A dictionary describing how the field has changed. This is guaranteed to havenewandoldkeys, but may also containaddedandremovedkeys as well.- Returns:
The HTML representation of the change entry.
- Return type:
- render_change_entry_value_html(info: Any, value: bool) SafeString[source]¶
Render the value for a change description string to HTML.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- get_dom_attributes() dict[str, str][source]¶
Return any additional attributes to include in the element.
By default, this returns nothing.
- Returns:
Additional key/value pairs for attributes to include in the rendered HTML element.
- Return type:
- value_as_html() SafeString[source]¶
Return the field rendered as HTML.
Because the value is included as a boolean attribute on the checkbox element, this just returns the empty string.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Returns:
The rendered field.
- Return type:
- class BaseDropdownField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
BaseReviewRequestField[str]Base class for a drop-down field.
- js_view_class: Optional[str] = 'RB.ReviewRequestFields.DropdownFieldView'[source]¶
The class name for the JavaScript view representing this field.
- options: Sequence[tuple[str, StrOrPromise]] = []¶
A list of the available options for the dropdown.
Each entry in the list should be a 2-tuple of (value, label). The values must be unique.
- load_value(review_request_details) Optional[str][source]¶
Load a value from the review request or draft.
- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request or draft.- Returns:
The loaded value.
- Return type:
- render_change_entry_value_html(info: Any, value: str) SafeString[source]¶
Render the value for a change description string to HTML.
Changed in version 7.1: This is now expected to return a
SafeString, and this will be required in Review Board 9. Subclasses must use functions likedjango.utils.html.format_html().- Parameters:
- Returns:
The rendered change entry.
- Return type:
- value_as_html() SafeString[source]¶
Return the field rendered as HTML.
Select tags are funny kinds of inputs, and need a bunch of
<option>elements inside them. This renders the “value” of the field as those options, to fit in with the base field’s template.- Returns:
The rendered field.
- Return type:
- class BaseDateField(review_request_details: BaseReviewRequestDetails, request: Optional[HttpRequest] = None)[source]¶
Bases:
BaseEditableField[str]Base class for a date field.
- js_view_class: Optional[str] = 'RB.ReviewRequestFields.DateFieldView'[source]¶
The class name for the JavaScript view representing this field.
- load_value(review_request_details: BaseReviewRequestDetails) str[source]¶
Load a value from the review request or draft.
- Parameters:
review_request_details (
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request or draft.- Returns:
The loaded value.
- Return type:
- get_review_request_fields() Iterator[type[reviewboard.reviews.fields.BaseReviewRequestField]][source]¶
Yield all registered field classes.
- Yields:
type– The field classes, as subclasses ofBaseReviewRequestField
- get_review_request_fieldsets(include_change_entries_only: bool = False) Sequence[type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]][source]¶
Return a list of all registered fieldset classes.
As an internal optimization, the “main” fieldset can be filtered out, to help with rendering the side of the review request page.
- get_review_request_fieldset(fieldset_id: str) Optional[type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]][source]¶
Return the fieldset with the specified ID.
- Parameters:
fieldset_id (
str) – The fieldset’s ID.- Returns:
The requested fieldset, or
Noneif it could not be found.- Return type:
- get_review_request_field(field_id: str) Optional[type[reviewboard.reviews.fields.BaseReviewRequestField]][source]¶
Return the field with the specified ID.
- Parameters:
field_id (
str) – The field’s ID.- Returns:
The requested field, or
Noneif it could not be found.- Return type:
- register_review_request_fieldset(fieldset: type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]) None[source]¶
Register a custom review request fieldset.
The fieldset must have a
fieldset_idattribute. This ID must be unique across all registered fieldsets, or an exception will be thrown.- Parameters:
fieldset (
type) – TheBaseReviewRequestFieldSetsubclass.- Raises:
djblets.registries.errors.ItemLookupError – This will be thrown if a fieldset is already registered with the same ID.
- unregister_review_request_fieldset(fieldset: type[reviewboard.reviews.fields.BaseReviewRequestFieldSet]) None[source]¶
Unregister a previously registered review request fieldset.
- Parameters:
fieldset (
type) – TheBaseReviewRequestFieldSetsubclass.- Raises:
djblets.registries.errors.ItemLookupError – This will be thrown if the fieldset is not already registered.