reviewboard.reviews.models¶
-
class
BaseComment
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
-
can_change_issue_status
(user)[source]¶ Returns whether the user can change the issue status.
Currently, this is allowed for: - The user who owns the review request. - The user who opened the issue (posted the comment).
-
objects
¶
-
-
class
Comment
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.models.base_comment.BaseComment
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.
-
class
DefaultReviewer
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Represents reviewers automatically added to review requests.
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.Note that this is keyed off the same LocalSite as its “repository” member.
-
is_mutable_by
(user)[source]¶ Returns whether the user can modify or delete this default reviewer.
Only those with the default_reviewer.change_group permission (such as administrators) can modify or delete default reviewers not bound to a LocalSite.
LocalSite administrators can modify or delete them on their LocalSites.
-
-
class
FileAttachmentComment
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.models.base_comment.BaseComment
A comment on a file attachment.
-
class
Group
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
A group of people who can be targetted for review.
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. If that e-mail address is blank, e-mails are sent individually to each member of that group.
-
clean
()[source]¶ Clean method for checking null unique_together constraints.
Django has a bug where unique_together constraints for foreign keys aren’t checked properly if one of the relations is null. This means that users who aren’t using local sites could create multiple groups with the same name.
-
is_accessible_by
(user, request=None, silent=False)[source]¶ Returns true if the user can access this group.
-
-
class
Review
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
A review of a review request.
-
delete
()[source]¶ Deletes this review.
This will enforce that all contained comments are also deleted.
-
public_body_bottom_replies
(user=None)[source]¶ Returns a list of public replies to this review’s body bottom.
-
public_body_top_replies
(user=None)[source]¶ Returns a list of public replies to this review’s body top.
-
publish
(user=None, trivial=False, request=None)[source]¶ Publishes this review.
This will make the review public and update the timestamps of all contained comments.
-
-
class
ReviewRequest
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails
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.
-
ISSUE_COUNTER_FIELDS
= {u’R’: u’issue_resolved_count’, u’D’: u’issue_dropped_count’, u’O’: u’issue_open_count’}[source]¶
-
STATUSES
= ((u’P’, _(u’Pending Review’)), (u’S’, _(u’Submitted’)), (u’D’, _(u’Discarded’)))[source]¶
-
approval_failure
[source]¶ Returns the error indicating why a review request isn’t approved.
If
approved
isFalse
, this will provide the text describing why it wasn’t approved.Extensions may customize approval by providing their own ReviewRequestApprovalHook.
-
approved
[source]¶ Returns whether or not a review request is approved by reviewers.
On a default installation, a review request is approved if it has at least one Ship It!, and doesn’t have any open issues.
Extensions may customize approval by providing their own ReviewRequestApprovalHook.
-
changeset_is_pending
(commit_id)[source]¶ Returns whether the associated changeset is pending commit.
For repositories that support it, this will return whether the associated changeset is pending commit. This requires server-side knowledge of the change.
-
close
(type, user=None, description=None, rich_text=False)[source]¶ Closes the review request.
The type must be one of SUBMITTED or DISCARDED.
-
get_blocks
()[source]¶ Returns the list of review request this one blocks.
The returned value will be cached for future lookups.
-
get_close_description
()[source]¶ Returns a tuple (description, is_rich_text) for the close text.
This is a helper which is used to gather the data which is rendered in the close description boxes on various pages.
-
get_diffsets
()[source]¶ Returns a list of all diffsets on this review request.
This will also fetch all associated FileDiffs, as well as a count of the number of files (stored in DiffSet.file_count).
-
get_draft
(user=None)[source]¶ 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
(diffsets=None, reviews=None)[source]¶ 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)[source]¶ Returns all new reviews since last viewing this review request.
This will factor in the time the user last visited the review request, and find any reviews that have been added or updated since.
-
get_pending_review
(user)[source]¶ Returns the pending review owned by the specified user, if any.
This will return an actual review, not a reply to a review.
-
get_review_request
()[source]¶ Returns this review request.
This is provided so that consumers can be passed either a ReviewRequest or a ReviewRequestDraft and retrieve the actual ReviewRequest regardless of the object.
-
is_accessible_by
(user, local_site=None, request=None, silent=False)[source]¶ Returns whether or not the user can read this review request.
This performs several checks to ensure that the user has access. This user has access if:
- The review request is public or the user can modify it (either by being an owner or having special permissions).
- The repository is public or the user has access to it (either by being explicitly on the allowed users list, or by being a member of a review group on that list).
- The user is listed as a requested reviewer or the user has access to one or more groups listed as requested reviewers (either by being a member of an invite-only group, or the group being public).
-
is_status_mutable_by
(user)[source]¶ Returns whether the user can modify this review request’s status.
-
-
class
ReviewRequestDraft
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.models.base_review_request_details.BaseReviewRequestDetails
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.
-
copy_fields_to_request
(review_request)[source]¶ Copies the draft information to the review request and updates the draft’s change description.
-
static
create
(review_request)[source]¶ 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.
-
publish
(review_request=None, user=None, trivial=False, send_notification=True)[source]¶ Publishes this draft.
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 draft’s assocated ReviewRequest object will be used if one isn’t passed in.
The keys that may be saved in
fields_changed
in the ChangeDescription are:summary
description
testing_done
bugs_closed
depends_on
branch
target_groups
target_people
screenshots
screenshot_captions
diff
- Any custom field IDs
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 fieldnew
: The new value of the field
For the
diff
field, there is only ever anadded
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_commit_id
(commit_id)[source]¶ Update the data from a server-side changeset.
If the commit ID refers to a pending changeset on an SCM which stores such things server-side (like Perforce), the details like the summary and description will be updated with the latest information.
If the change number is the commit ID of a change which exists on the server, the summary and description will be set from the commit’s message, and the diff will be fetched from the SCM.
Parameters: commit_id (unicode) – The commit ID or changeset ID that the draft will update from.
-
update_from_committed_change
(commit_id)[source]¶ Update from a committed change present on the server.
Fetches the commit message and diff from the repository and sets the relevant fields.
Parameters: commit_id (unicode) – The commit ID to update from.
-
update_from_pending_change
(commit_id, changeset)[source]¶ Update the data from a server-side pending changeset.
This will fetch the metadata from the server and update the fields on the draft.
Parameters: - commit_id (unicode) – The changeset ID that the draft will update from.
- changeset (reviewboard.scmtools.core.ChangeSet) – The changeset information to update from.
-
-
class
Screenshot
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
A screenshot associated with a review request.
Like diffs, a screenshot can have comments associated with it. These comments are of type
reviewboard.reviews.models.ScreenshotComment
.-
image
¶ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
-
-
class
ScreenshotComment
(*args, **kwargs)[source]¶ Bases:
reviewboard.reviews.models.base_comment.BaseComment
A comment on a screenshot.