reviewboard.reviews.models - Review Request Database Models¶
Module Contents¶
Review Requests¶
- class reviewboard.reviews.models.DefaultReviewer(*args, **kwargs)¶
A default reviewer entry automatically adds default reviewers to a review request when the diff modifies a file matching the file_regex pattern specified.
This is useful when different groups own different parts of a codebase. Adding DefaultReviewer entries ensures that the right people will always see the review request and discussions.
A file_regex of ".*" will add the specified reviewers by default for every review request.
- name¶
- A description of this default reviewer entry. This is only shown in the administration UI.
- file_regex¶
- A regular expression used to match file paths. Any file path found in a diff that matches this regular expression will have the default reviewers set on the review request.
- people¶
- The User entries that should be set as reviewers. This can be empty.
- class reviewboard.reviews.models.Group(*args, **kwargs)¶
A group of reviewers identified by a name. This is usually used to separate teams at a company or components of a project.
Each group can have an e-mail address associated with it, sending all review requests and replies to that address.
- name¶
- The ID name of the group. This is the name users type in to the reviewer lists and see in the dashboard.
- display_name¶
- The human-readable name or description of the group.
- mailing_list¶
- The mailing list that review request and review e-mails are sent to.
- users¶
- A list of User entries that belong to the group. This list can be empty.
- class reviewboard.reviews.models.ReviewRequest(*args, **kwargs)¶
A review request.
This is one of the primary models in Review Board. Most everything is associated with a review request.
The ReviewRequest model contains detailed information on a review request. Some fields are user-modifiable, while some are used for internal state.
- PENDING_REVIEW¶
- A review request status indicating that the review request is still pending review.
- SUBMITTED¶
- A review request status indicating that the review request has been submitted and closed.
- DISCARDED¶
- A review request status indicating that the review request has been discarded.
- STATUSES¶
- A mapping in the form of a list of tuples between status codes (PENDING_REVIEW, SUBMITTED, and DISCARDED) and their human-readable names.
- submitter¶
- time_added¶
- last_updated¶
- status¶
- public¶
- changenum¶
- repository¶
- email_message_id¶
- time_emailed¶
- summary¶
- description¶
- testing_done¶
- bugs_closed¶
- diffset_history¶
- branch¶
- target_groups¶
- target_people¶
- screenshots¶
- inactive_screenshots¶
- changedescs¶
- add_default_reviewers()¶
Add default reviewers to this review request based on the diffset.
This method goes through the DefaultReviewer objects in the database and adds any missing reviewers based on regular expression comparisons with the set of files in the diff.
- changeset_is_pending()¶
- Returns True if the current changeset associated with this review request is pending under SCM.
- close(type, user=None)¶
- Closes the review request. The type must be one of SUBMITTED or DISCARDED.
- get_bug_list()¶
- Returns a sorted list of bugs associated with this review request.
- get_draft(user=None)¶
- Returns the draft of the review request. If a user is specified, than the draft will be returned only if owned by the user. Otherwise, None will be returned.
- get_last_activity()¶
Returns the last public activity information on the review request.
This will return the last object updated, along with the timestamp of that object. It can be used to judge whether something on a review request has been made public more recently.
- get_new_reviews(user)¶
- Returns any new reviews since the user last viewed the review request.
- get_pending_review(user)¶
- Returns the pending review owned by the specified user, if any. This will return an actual review, not a reply to a review.
- get_public_reviews()¶
- Returns all public top-level reviews for this review request.
- increment_ship_it()¶
- Atomicly increments the ship-it count on the review request.
- is_accessible_by(user)¶
- Returns true if the user can read this review request
- is_mutable_by(user)¶
- Returns true if the user can modify this review request
- publish(user)¶
- Save the current draft attached to this review request. Send out the associated email. Returns the review request that was saved.
- reopen(user=None)¶
- Reopens the review request for review.
- update_from_changenum(changenum)¶
- Updates this review request from the specified changeset’s contents on the server.
- class reviewboard.reviews.models.ReviewRequestDraft(*args, **kwargs)¶
A draft of a review request.
When a review request is being modified, a special draft copy of it is created containing all the details of the review request. This copy can be modified and eventually saved or discarded. When saved, the new details are copied back over to the originating ReviewRequest.
- review_request¶
- last_updated¶
- summary¶
- description¶
- testing_done¶
- bugs_closed¶
- diffset¶
- changedesc¶
- branch¶
- target_groups¶
- target_people¶
- screenshots¶
- inactive_screenshots¶
- submitter¶
- add_default_reviewers()¶
Add default reviewers to this draft based on the diffset.
This method goes through the DefaultReviewer objects in the database and adds any missing reviewers based on regular expression comparisons with the set of files in the diff.
- static create(review_request)¶
Creates a draft based on a review request.
This will copy over all the details of the review request that we care about. If a draft already exists for the review request, the draft will be returned.
- get_bug_list()¶
- Returns a sorted list of bugs associated with this review request.
- publish(review_request=None, user=None, send_notification=True)¶
Publishes this draft. Uses the draft’s assocated ReviewRequest object if one isn’t passed in.
This updates and returns the draft’s ChangeDescription, which contains the changed fields. This is used by the e-mail template to tell people what’s new and interesting.
The keys that may be saved in ‘fields_changed’ in the ChangeDescription are:
- ‘summary’
- ‘description’
- ‘testing_done’
- ‘bugs_closed’
- ‘branch’
- ‘target_groups’
- ‘target_people’
- ‘screenshots’
- ‘screenshot_captions’
- ‘diff’
Each field in ‘fields_changed’ represents a changed field. This will save fields in the standard formats as defined by the ‘ChangeDescription’ documentation, with the exception of the ‘screenshot_captions’ and ‘diff’ fields.
For the ‘screenshot_captions’ field, the value will be a dictionary of screenshot ID/dict pairs with the following fields:
- ‘old’: The old value of the field
- ‘new’: The new value of the field
For the ‘diff’ field, there is only ever an ‘added’ field, containing the ID of the new diffset.
The ‘send_notification’ parameter is intended for internal use only, and is there to prevent duplicate notifications when being called by ReviewRequest.publish.
- update_from_changenum(changenum)¶
- Updates this draft from the specified changeset’s contents on the server.
Reviews¶
- class reviewboard.reviews.models.Comment(*args, **kwargs)¶
A comment made on a diff.
A comment can belong to a single filediff or to an interdiff between two filediffs. It can also have multiple replies.
- filediff¶
- The FileDiff the comment is associated with. The line numbers will be based on the referenced file with this diff applied.
- interfilediff¶
- The FileDiff used as the second part of an interdiff range. This may be None.
- reply_to¶
- The Comment that this comment is replying to, if any. This may be None, indicating this is a comment in a top-level review.
- timestamp¶
- The timestamp of the comment.
- text¶
- The comment text.
- first_line¶
- The first line of the file (creating by taking into account the filediff and interfilediff) that the comment coer.
- num_lines¶
- The number of lines that the comment covers.
- last_line¶
- The last line in the range. This is the equivalent of first_line + num_lines.
- public_replies(user=None)¶
- Returns a list of public replies to this comment, optionally specifying the user replying.
- class reviewboard.reviews.models.Review(*args, **kwargs)¶
A review of a review request.
- review_request¶
- user¶
- timestamp¶
- public¶
- ship_it¶
- base_reply_to¶
- email_message_id¶
- time_emailed¶
- body_top¶
- body_bottom¶
- body_top_reply_to¶
- body_bottom_reply_to¶
- comments¶
- screenshot_comments¶
- delete()¶
Deletes this review.
This will enforce that all contained comments are also deleted.
- get_pending_reply(user)¶
- Returns the pending reply to this review owned by the specified user, if any.
- is_reply()¶
- Returns whether or not this review is a reply to another review.
- public_replies()¶
- Returns a list of public replies to this review.
- publish(user=None)¶
Publishes this review.
This will make the review public and update the timestamps of all contained comments.
- class reviewboard.reviews.models.Screenshot(*args, **kwargs)¶
A screenshot associated with a review request.
Like diffs, a screenshot can have comments associated with it. These comments are of type :model:`reviews.ScreenshotComment`.
- caption¶
- The caption of the screenshot, if any. This can be blank. The maximum length of this field is 256 characters.
- draft_caption¶
- The draft caption of this screenshot. This may exist if the screenshot’s caption has been changed when a ReviewRequestDraft for the review request exists. This maximum length of this field is 256 characters.
- image¶
- The image information. This is an ImageField pointing to the file of location of the file on disk and the path relative to the web server.
- get_thumbnail_url()¶
- Returns the URL for the thumbnail, creating it if necessary.
- thumb()¶
- Creates a thumbnail of this screenshot and returns the HTML output embedding the thumbnail.
- class reviewboard.reviews.models.ScreenshotComment(*args, **kwargs)¶
A comment on a screenshot.
- screenshot¶
- The Screenshot that this comment is about.
- reply_to¶
- The ScreenshotComment that this comment is a reply to, if any. This can be empty.
- timestamp¶
- The timestamp of this comment.
- text¶
- The text of this comment.
- x¶
- The X location for the comment block on the screenshot.
- y¶
- The Y location for the comment block on the screenshot.
- w¶
- The width of the comment block on the screenshot.
- h¶
- The height of the comment block on the screenshot.
- get_image_url()¶
- Returns the URL for the thumbnail, creating it if necessary.
- image()¶
- Generates the cropped part of the screenshot referenced by this comment and returns the HTML markup embedding it.
- public_replies(user=None)¶
- Returns a list of public replies to this comment, optionally specifying the user replying.