reviewboard.reviews.ui.base¶
-
class
ReviewUI
(review_request, obj)[source]¶ Bases:
object
-
set_diff_against
(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
.
-
render_to_response
(request)[source]¶ 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.
-
get_comment_thumbnail
(comment)[source]¶ 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.
-
get_comment_link_url
(comment)[source]¶ 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.
-
get_comment_link_text
(comment)[source]¶ 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.
-
get_js_model_data
()[source]¶ Returns data to pass to the JavaScript Model during instantiation.
This data will be passed as attributes to the reviewable model when constructed.
-
get_js_view_data
()[source]¶ Returns data to pass to the JavaScript View during instantiation.
This data will be passed as options to the reviewable view when constructed.
-
get_comments_json
()[source]¶ 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.
-
serialize_comments
(comments)[source]¶ 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.
-
-
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.
-
get_comments
()[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.
-
get_js_model_data
()[source]¶ 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.
-