Jump to >


class ReviewUI(review_request, obj)[source]

Bases: object

name = None[source]
model = None[source]
template_name = u’reviews/ui/default.html’[source]
object_key = u’obj’[source]
diff_object_key = u’diff_against_obj’[source]
allow_inline = False[source]
supports_diffing = False[source]
css_bundle_names = [][source]
js_bundle_names = [][source]
js_files = [][source]
js_model_class = None[source]
js_view_class = None[source]
__init__(review_request, obj)[source]

Sets the object to generate a diff against.

This can only be called on review UIs that support diffing, and must be called before rendering.

is_enabled_for(user=None, review_request=None, file_attachment=None, **kwargs)[source]

Returns whether the review UI is enabled under the given criteria.

This can enable or disable a review UI’s functionality, both on the file attachment thumbnail and review UI page, depending on the user, review request, file attachment, or some state associated with one or more of those.

When this is called, the arguments are always passed as keyword arguments. Subclasses don’t need to accept all the arguments, as long as they take a **kwargs.


Renders the review UI to an HttpResponse.

This is used to render a page dedicated to the review UI, complete with the standard Review Board chrome.

render_to_string(request, inline=True)[source]

Renders the review UI to an HTML string.

This renders the review UI to a string for use in embedding into either an existing page or a new page.

If inline is True, the rendered review UI will be embeddable into an existing page.

If inline is False, it will be rendered for use as a full, standalone page, compelte with Review Board chrome.


Returns the thumbnail (as HTML) for a comment.

If this ReviewUI can render comments with a contextual thumbnail, it should return HTML representing that comment. Otherwise, return None in order to use the fallback.

Returns the link for a comment.

This will normally just link to the review UI itself, but some may want to specialize the URL to link to a specific location within the file.

Return the text to link to a comment.

This will normally just return the file attachment’s display name, but some may want to specialize to list things like page numbers or sections.


Returns data to pass to the JavaScript Model during instantiation.

This data will be passed as attributes to the reviewable model when constructed.


Returns data to pass to the JavaScript View during instantiation.

This data will be passed as options to the reviewable view when constructed.


Returns a JSON-serialized representation of comments for a template.

The result of this can be used directly in a template to provide comments to JavaScript functions.


Serializes the comments for the review UI target.

By default, this will return a list of serialized comments, but it can be overridden to return other list or dictionary-based representations, such as comments grouped by an identifier or region. These representations must be serializable into JSON.


Serializes a comment.

This will provide information on the comment that may be useful to the JavaScript code.

Subclasses that want to add additional data should generally augment the result of this function and not replace it.

class FileAttachmentReviewUI(review_request, obj)[source]

Bases: reviewboard.reviews.ui.base.ReviewUI

Base class for Review UIs for file attachments.

Review UIs that deal with FileAttachment objects can subclass this to provide the common functionality for their review UI.

This class handles fetching and serializing comments, locating a correct FileAttachmentReviewUI subclass for a given mimetype, and feeding data to the JavaScript AbstractReviewable model.

This also handles much of the work for diffing FileAttachments.

name = u’Unknown file type’[source]
object_key = u’file’[source]
diff_object_key = u’diff_against_file’[source]
supported_mimetypes = [][source]
js_model_class = u’RB.DummyReviewable’[source]
js_view_class = u’RB.DummyReviewableView’[source]

Returns a list of comments made on the FileAttachment.

If this review UI is showing a diff between two FileAttachments, the comments returned will be specific to that diff.


Returns model data for the JavaScript AbstractReviewable subclass.

This will provide the fileAttachmentID and, if diffing, the diffAgainstFileAttachmentID.

Subclasses can override this to return additional data.

classmethod get_best_handler(mimetype)[source]

Returns the handler and score that that best fit the mimetype.

classmethod for_type(attachment)[source]

Returns the handler that is the best fit for provided mimetype.


Registers a review UI class.

This will register a review UI. Review Board will use it to display a UI when reviewing a supported file attachment.

Only FileAttachmentReviewUI subclasses are supported.


Unregisters a review UI class.

This will unregister a previously registered review UI.

Only FileAttachmentReviewUI subclasses are supported. The class must have been registered beforehand or a ValueError will be thrown.