reviewboard.reviews.builtin_fields¶
-
class
BuiltinFieldMixin
(*args, **kwargs)[source]¶ Bases:
object
Mixin for built-in fields.
This overrides some functions to work with native fields on a ReviewRequest or ReviewRequestDraft, rather than working with those stored in extra_data.
-
__init__
(*args, **kwargs)[source]¶ Initialize the field.
Parameters: - *args (tuple) – Positional arguments to pass through to the superclass.
- **kwargs (dict) – Keyword arguments to pass through to the superclass.
-
-
class
BuiltinTextAreaFieldMixin
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
Mixin for built-in text area fields.
This will ensure that the text is always rendered in Markdown, no matter whether the source text is plain or Markdown. It will still escape the text if it’s not in Markdown format before rendering.
-
class
ReviewRequestPageDataMixin
(review_request_details, data=None, *args, **kwargs)[source]¶ Bases:
object
Mixin for internal fields needing access to the page data.
These are used by fields that operate on state generated when creating the review request page. The view handling that page makes a lot of queries, and stores the results. This mixin allows access to those results, preventing additional queries.
The data structure is not meant to be public API, and this mixin should not be used by any classes outside this file.
By default, this will not render or handle any value loading or change entry recording. Subclasses must implement those manually.
-
__init__
(review_request_details, data=None, *args, **kwargs)[source]¶ Initialize the mixin.
Parameters: - review_request_details (reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request (or the active draft thereof). In practice
this will either be a
reviewboard.reviews.models.ReviewRequest
or areviewboard.reviews.models.ReviewRequestDraft
. - data (reviewboard.reviews.detail.ReviewRequestPageData) – The data already queried for the review request page.
- *args (tuple) – Additional positional arguments.
- **kwargs (dict) – Additional keyword arguments.
- review_request_details (reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails) – The review request (or the active draft thereof). In practice
this will either be a
-
load_value
(review_request_details)[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: object
-
record_change_entry
(changedesc, old_value, new_value)[source]¶ Record information on the changed values in a ChangeDescription.
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.
-
-
class
BaseCaptionsField
(review_request_details, data=None, *args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.ReviewRequestPageDataMixin
,reviewboard.reviews.fields.BaseReviewRequestField
Base class for rendering captions for attachments.
This serves as a base for FileAttachmentCaptionsField and ScreenshotCaptionsField. It provides the base rendering and for caption changes on file attachments or screenshots.
-
render_change_entry_html
(info)[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.
Parameters: info (dict) – A dictionary describing how the field has changed. This is guaranteed to have new
andold
keys, but may also containadded
andremoved
keys as well.Returns: The HTML representation of the change entry. Return type: unicode
-
serialize_change_entry
(changedesc)[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: list
-
-
class
BaseModelListEditableField
(review_request_details, request=None)[source]¶ Bases:
reviewboard.reviews.fields.BaseCommaEditableField
Base class for editable comma-separated list of model instances.
This is used for built-in classes that work with ManyToManyFields.
-
has_value_changed
(old_value, new_value)[source]¶ Return whether the value has changed.
Parameters: Returns: Whether the value of the field has changed.
Return type:
-
record_change_entry
(changedesc, old_value, new_value)[source]¶ Record information on the changed values in a ChangeDescription.
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.
-
-
class
StatusField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseReviewRequestField
The Status field on a review request.
-
class
SummaryField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseEditableField
The Summary field on a review request.
-
class
DescriptionField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinTextAreaFieldMixin
,reviewboard.reviews.fields.BaseTextAreaField
The Description field on a review request.
-
class
TestingDoneField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinTextAreaFieldMixin
,reviewboard.reviews.fields.BaseTextAreaField
The Testing Done field on a review request.
-
class
OwnerField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseEditableField
The Owner field on a review request.
-
model
[source]¶ alias of
django.contrib.auth.models.User
-
js_view_class
= u'RB.ReviewRequestFields.OwnerFieldView'[source]¶ The class name for the JavaScript view representing this field.
-
render_value
(user)[source]¶ Render the value in the field.
Parameters: user (django.contrib.auth.models.User) – The value to render. Returns: The rendered value. Return type: unicode
-
record_change_entry
(changedesc, old_value, new_value)[source]¶ Record information on the changed values in a ChangeDescription.
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.
-
render_change_entry_value_html
(info, item)[source]¶ Render the value for a change description string to HTML.
Parameters: Returns: The rendered change entry.
Return type: unicode
-
serialize_change_entry
(changedesc)[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: dict
-
-
class
RepositoryField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseReviewRequestField
The Repository field on a review request.
-
class
BranchField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseEditableField
The Branch field on a review request.
-
class
BugsField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseCommaEditableField
The Bugs field on a review request.
-
js_view_class
= u'RB.ReviewRequestFields.BugsFieldView'[source]¶ The class name for the JavaScript view representing this field.
-
load_value
(review_request_details)[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: object
-
save_value
(value)[source]¶ Save the value in the review request or draft.
Parameters: value (object) – The new value for the field.
-
-
class
DependsOnField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.builtin_fields.BaseModelListEditableField
The Depends On field on a review request.
-
js_view_class
= u'RB.ReviewRequestFields.DependsOnFieldView'[source]¶ The class name for the JavaScript view representing this field.
-
-
class
BlocksField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseReviewRequestField
The Blocks field on a review request.
-
class
ChangeField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseReviewRequestField
The Change field on a review request.
This is shown for repositories supporting changesets. The change number is similar to a commit ID, with the exception that it’s only ever stored on the ReviewRequest and never changes.
If both
changenum
andcommit_id
are provided on the review request, only this field will be shown, as both are likely to have values.
-
class
CommitField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseReviewRequestField
The Commit field on a review request.
This displays the ID of the commit the review request is representing.
Since the
commit_id
andchangenum
fields are both populated, we let ChangeField take precedence. It knows how to render information based on a changeset ID.
-
class
DiffField
(review_request_details, data=None, *args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.ReviewRequestPageDataMixin
,reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseReviewRequestField
Represents a newly uploaded diff on a review request.
This is not shown as an actual displayable field on the review request itself. Instead, it is used only during the ChangeDescription population and processing steps.
-
render_change_entry_html
(info)[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.
Parameters: info (dict) – A dictionary describing how the field has changed. This is guaranteed to have new
andold
keys, but may also containadded
andremoved
keys as well.Returns: The HTML representation of the change entry. Return type: unicode
-
has_value_changed
(old_value, new_value)[source]¶ Return whether the value has changed.
Parameters: Returns: Whether the value of the field has changed.
Return type:
-
load_value
(review_request_details)[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: object
-
record_change_entry
(changedesc, unused, diffset)[source]¶ Record information on the changed values in a ChangeDescription.
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)[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: dict
-
-
class
FileAttachmentCaptionsField
(review_request_details, data=None, *args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BaseCaptionsField
Renders caption changes for file attachments.
This is not shown as an actual displayable field on the review request itself. Instead, it is used only during the ChangeDescription rendering stage. It is not, however, used for populating entries in ChangeDescription.
-
class
FileAttachmentsField
(review_request_details, data=None, *args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.ReviewRequestPageDataMixin
,reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.fields.BaseCommaEditableField
Renders removed or added file attachments.
This is not shown as an actual displayable field on the review request itself. Instead, it is used only during the ChangeDescription rendering stage. It is not, however, used for populating entries in ChangeDescription.
-
get_change_entry_sections_html
(info)[source]¶ Return sections of change entries with titles and rendered HTML.
Parameters: info (dict) – A dictionary describing how the field has changed. This is guaranteed to have new
andold
keys, but may also containadded
andremoved
keys as well.Returns: A list of the change entry sections. Return type: list of dict
-
render_change_entry_html
(values)[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.
Parameters: info (list) – A list of the changed file attachments. Each item is a 3-tuple containing the caption
,filename
, and thepk
of the file attachment in the database.Returns: The HTML representation of the change entry. Return type: unicode
-
-
class
ScreenshotCaptionsField
(review_request_details, data=None, *args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BaseCaptionsField
Renders caption changes for screenshots.
This is not shown as an actual displayable field on the review request itself. Instead, it is used only during the ChangeDescription rendering stage. It is not, however, used for populating entries in ChangeDescription.
-
class
ScreenshotsField
(review_request_details, request=None)[source]¶ Bases:
reviewboard.reviews.fields.BaseCommaEditableField
Renders removed or added screenshots.
This is not shown as an actual displayable field on the review request itself. Instead, it is used only during the ChangeDescription rendering stage. It is not, however, used for populating entries in ChangeDescription.
-
class
TargetGroupsField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.builtin_fields.BaseModelListEditableField
The Target Groups field on a review request.
-
class
TargetPeopleField
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.builtin_fields.BuiltinFieldMixin
,reviewboard.reviews.builtin_fields.BaseModelListEditableField
The Target People field on a review request.
-
model
[source]¶ alias of
django.contrib.auth.models.User
-
-
class
InformationFieldSet
(review_request_details)[source]¶ Bases:
reviewboard.reviews.fields.BaseReviewRequestFieldSet
-
field_classes
= [<class 'reviewboard.reviews.builtin_fields.OwnerField'>, <class 'reviewboard.reviews.builtin_fields.RepositoryField'>, <class 'reviewboard.reviews.builtin_fields.BranchField'>, <class 'reviewboard.reviews.builtin_fields.BugsField'>, <class 'reviewboard.reviews.builtin_fields.DependsOnField'>, <class 'reviewboard.reviews.builtin_fields.BlocksField'>, <class 'reviewboard.reviews.builtin_fields.ChangeField'>, <class 'reviewboard.reviews.builtin_fields.CommitField'>][source]¶
-
-
class
ChangeEntryOnlyFieldSet
(review_request_details)[source]¶ Bases:
reviewboard.reviews.fields.BaseReviewRequestFieldSet
-
field_classes
= [<class 'reviewboard.reviews.builtin_fields.DiffField'>, <class 'reviewboard.reviews.builtin_fields.FileAttachmentCaptionsField'>, <class 'reviewboard.reviews.builtin_fields.ScreenshotCaptionsField'>, <class 'reviewboard.reviews.builtin_fields.FileAttachmentsField'>, <class 'reviewboard.reviews.builtin_fields.ScreenshotsField'>, <class 'reviewboard.reviews.builtin_fields.StatusField'>][source]¶
-