Jump to >

reviewboard.reviews.models

class BaseComment(*args, **kwargs)[source]

Bases: django.db.models.base.Model

DROPPED = u’D’[source]
ISSUE_STATUSES = ((u’O’, _(u’Open’)), (u’R’, _(u’Resolved’)), (u’D’, _(u’Dropped’)))[source]
class Meta[source]
abstract = False[source]
app_label = u’reviews’[source]
ordering = [u’timestamp’][source]
OPEN = u’O’[source]
RESOLVED = u’R’[source]
__init__(*args, **kwargs)[source]
__str__()[source]
__unicode__()[source]
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).

get_extra_data_json(model_instance)[source]
get_issue_status_display(*moreargs, **morekwargs)[source]
get_next_by_timestamp(*moreargs, **morekwargs)[source]
get_previous_by_timestamp(*moreargs, **morekwargs)[source]
get_review()[source]
get_review_request()[source]
get_review_url()[source]
is_accessible_by(user)[source]

Returns whether the user can access this comment.

is_mutable_by(user)[source]

Returns whether the user can modify this comment.

is_reply()[source]

Returns whether this comment is a reply to another comment.

static issue_status_to_string(status)[source]
static issue_string_to_status(status)[source]
objects
public_replies(user=None)[source]

Returns a list of public replies to this comment, optionally specifying the user replying.

reply_to[source]
save(**kwargs)[source]
set_extra_data_json(model_instance, json)[source]
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.

anchor_prefix = u’comment’[source]
comment_type = u’diff’[source]
filediff[source]
get_absolute_url(*moreargs, **morekwargs)[source]
get_extra_data_json(model_instance)[source]
get_issue_status_display(*moreargs, **morekwargs)[source]
get_next_by_timestamp(*moreargs, **morekwargs)[source]
get_previous_by_timestamp(*moreargs, **morekwargs)[source]
interfilediff[source]
last_line[source]
objects = <djblets.db.managers.ConcurrencyManager object>[source]
replies[source]
reply_to[source]
review[source]
set_extra_data_json(model_instance, json)[source]
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.

__str__()[source]
__unicode__()[source]
groups[source]
is_accessible_by(user)[source]

Returns whether the user can access this default reviewer.

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.

local_site[source]
objects = <reviewboard.reviews.managers.DefaultReviewerManager object>[source]
people[source]
repository[source]
class FileAttachmentComment(*args, **kwargs)[source]

Bases: reviewboard.reviews.models.base_comment.BaseComment

A comment on a file attachment.

anchor_prefix = u’fcomment’[source]
comment_type = u’file’[source]
diff_against_file_attachment[source]
file_attachment[source]
get_absolute_url(*moreargs, **morekwargs)[source]

Returns the URL for this comment.

get_extra_data_json(model_instance)[source]
get_issue_status_display(*moreargs, **morekwargs)[source]

Returns the text for the link to the file.

get_next_by_timestamp(*moreargs, **morekwargs)[source]
get_previous_by_timestamp(*moreargs, **morekwargs)[source]
objects = <djblets.db.managers.ConcurrencyManager object>[source]
replies[source]
reply_to[source]
review[source]
review_ui[source]

Decorator that converts a method with a single self argument into a property cached on the instance.

set_extra_data_json(model_instance, json)[source]
thumbnail[source]

Returns the thumbnail for this comment, if any, as HTML.

The thumbnail will be generated from the appropriate ReviewUI, if there is one for this type of file.

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.

__str__()[source]
__unicode__()[source]
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.

decrement_incoming_request_count(model_instance, *args, **kwargs)[source]
defaultreviewer_set[source]
drafts[source]
get_absolute_url(*moreargs, **morekwargs)[source]
get_extra_data_json(model_instance)[source]
incoming_request_count = <djblets.db.fields.CounterField: incoming_request_count>[source]
increment_incoming_request_count(model_instance, *args, **kwargs)[source]
is_accessible_by(user, request=None, silent=False)[source]

Returns true if the user can access this group.

is_mutable_by(user)[source]

Returns whether or not the user can modify or delete the group.

The group is mutable by the user if they are an administrator with proper permissions, or the group is part of a LocalSite and the user is in the admin list.

local_site[source]
objects = <reviewboard.reviews.managers.ReviewGroupManager object>[source]
reinit_incoming_request_count(model_instance)[source]
reload_incoming_request_count(model_instance)[source]
repositories[source]
review_requests[source]
set_extra_data_json(model_instance, json)[source]
starred_by[source]
users[source]
class Review(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A review of a review request.

SHIP_IT_TEXT = u’Ship It!’[source]
__str__()[source]
__unicode__()[source]
base_reply_to[source]
body_bottom_replies[source]
body_bottom_reply_to[source]
body_top_replies[source]
body_top_reply_to[source]
comments[source]
delete()[source]

Deletes this review.

This will enforce that all contained comments are also deleted.

file_attachment_comments[source]
get_absolute_url(*moreargs, **morekwargs)[source]
get_all_comments(**kwargs)[source]

Return a list of all contained comments of all types.

get_extra_data_json(model_instance)[source]
get_next_by_timestamp(*moreargs, **morekwargs)[source]
get_participants()[source]

Returns a list of participants in a review’s discussion.

get_pending_reply(user)[source]

Returns the pending reply owned by the specified user.

get_previous_by_timestamp(*moreargs, **morekwargs)[source]
is_accessible_by(user)[source]

Returns whether the user can access this review.

is_mutable_by(user)[source]

Returns whether the user can modify this review.

is_reply()[source]

Returns whether or not this review is a reply to another review.

objects = <reviewboard.reviews.managers.ReviewManager object>[source]
participants[source]

Returns a list of participants in a review’s discussion.

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.

public_replies()[source]

Returns a list of public replies to this review.

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.

replies[source]
review_request[source]
reviewed_diffset[source]
save(**kwargs)[source]
screenshot_comments[source]
set_extra_data_json(model_instance, json)[source]
ship_it_only[source]

Decorator that converts a method with a single self argument into a property cached on the instance.

user[source]
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.

DISCARDED = u’D’[source]
ISSUE_COUNTER_FIELDS = {u’R’: u’issue_resolved_count’, u’D’: u’issue_dropped_count’, u’O’: u’issue_open_count’}[source]
PENDING_REVIEW = u’P’[source]
STATUSES = ((u’P’, _(u’Pending Review’)), (u’S’, _(u’Submitted’)), (u’D’, _(u’Discarded’)))[source]
SUBMITTED = u’S’[source]
approval_failure[source]

Returns the error indicating why a review request isn’t approved.

If approved is False, 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.

blocks[source]
can_publish()[source]
changedescs[source]
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.

commit[source]
decrement_issue_dropped_count(model_instance, *args, **kwargs)[source]
decrement_issue_open_count(model_instance, *args, **kwargs)[source]
decrement_issue_resolved_count(model_instance, *args, **kwargs)[source]
decrement_shipit_count(model_instance, *args, **kwargs)[source]
delete(**kwargs)[source]
depends_on[source]
diffset_history[source]
display_id[source]

Returns the ID that should be exposed to the user.

draft[source]
draft_blocks[source]
file_attachment_histories[source]
file_attachments[source]
get_absolute_url(*moreargs, **morekwargs)[source]
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_commit()[source]
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_display_id()[source]

Returns the ID that should be exposed to the user.

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_extra_data_json(model_instance)[source]
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_latest_diffset()[source]

Returns the latest diffset for this review request.

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_next_by_last_updated(*moreargs, **morekwargs)[source]
get_next_by_time_added(*moreargs, **morekwargs)[source]
get_participants()[source]

Returns a list of users who have discussed this review request.

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_previous_by_last_updated(*moreargs, **morekwargs)[source]
get_previous_by_time_added(*moreargs, **morekwargs)[source]
get_public_reviews()[source]

Returns all public top-level reviews for this review request.

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.

get_status_display(*moreargs, **morekwargs)[source]
inactive_file_attachments[source]
inactive_screenshots[source]
increment_issue_dropped_count(model_instance, *args, **kwargs)[source]
increment_issue_open_count(model_instance, *args, **kwargs)[source]
increment_issue_resolved_count(model_instance, *args, **kwargs)[source]
increment_shipit_count(model_instance, *args, **kwargs)[source]
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_deletable_by(user)[source]

Returns whether the user can delete this review request.

is_mutable_by(user)[source]

Returns whether the user can modify this review request.

is_status_mutable_by(user)[source]

Returns whether the user can modify this review request’s status.

issue_dropped_count = <djblets.db.fields.CounterField: issue_dropped_count>[source]
issue_open_count = <djblets.db.fields.CounterField: issue_open_count>[source]
issue_resolved_count = <djblets.db.fields.CounterField: issue_resolved_count>[source]
local_site[source]
objects = <reviewboard.reviews.managers.ReviewRequestManager object>[source]
participants[source]

Returns a list of users who have discussed this review request.

publish(user, trivial=False)[source]

Publishes the current draft attached to this review request.

The review request will be mark as public, and signals will be emitted for any listeners.

reinit_issue_dropped_count(model_instance)[source]
reinit_issue_open_count(model_instance)[source]
reinit_issue_resolved_count(model_instance)[source]
reinit_shipit_count(model_instance)[source]
reload_issue_dropped_count(model_instance)[source]
reload_issue_open_count(model_instance)[source]
reload_issue_resolved_count(model_instance)[source]
reload_shipit_count(model_instance)[source]
reopen(user=None)[source]

Reopens the review request for review.

repository[source]
reviews[source]
save(update_counts=False, **kwargs)[source]
screenshots[source]
set_commit(commit_id)[source]
set_extra_data_json(model_instance, json)[source]
shipit_count = <djblets.db.fields.CounterField: shipit_count>[source]
starred_by[source]
submitter[source]
target_groups[source]
target_people[source]
trophies[source]
visits[source]
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.

changedesc[source]
commit[source]
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.

depends_on[source]
diffset[source]
file_attachments[source]
get_extra_data_json(model_instance)[source]
get_latest_diffset()[source]

Returns the diffset for this draft.

get_next_by_last_updated(*moreargs, **morekwargs)[source]
get_previous_by_last_updated(*moreargs, **morekwargs)[source]
get_review_request()[source]

Returns the associated review request.

inactive_file_attachments[source]
inactive_screenshots[source]
is_accessible_by(user)[source]

Returns whether or not the user can access this draft.

is_mutable_by(user)[source]

Returns whether or not the user can modify this draft.

local_site[source]
objects = <djblets.db.managers.ConcurrencyManager object>[source]
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 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.

repository[source]
review_request[source]
screenshots[source]
set_extra_data_json(model_instance, json)[source]
submitter[source]
target_groups[source]
target_people[source]
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:
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.

__str__()[source]
__unicode__()[source]
comments[source]
drafts[source]
filename[source]

Returns the filename for display purposes.

get_absolute_url(*moreargs, **morekwargs)[source]
get_comments()[source]

Returns all the comments made on this screenshot.

get_review_request()[source]
get_thumbnail_url()[source]

Returns the URL for the thumbnail, creating it if necessary.

image

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

inactive_drafts[source]
inactive_review_request[source]
objects = <django.db.models.manager.Manager object>[source]
review_request[source]
save(**kwargs)[source]
thumb()[source]

Creates and returns HTML for this screenshot’s thumbnail.

class ScreenshotComment(*args, **kwargs)[source]

Bases: reviewboard.reviews.models.base_comment.BaseComment

A comment on a screenshot.

anchor_prefix = u’scomment’[source]
comment_type = u’screenshot’[source]
get_extra_data_json(model_instance)[source]
get_image_url()[source]

Returns the URL for the thumbnail, creating it if necessary.

get_issue_status_display(*moreargs, **morekwargs)[source]
get_next_by_timestamp(*moreargs, **morekwargs)[source]
get_previous_by_timestamp(*moreargs, **morekwargs)[source]
image()[source]

Returns HTML for a section of the screenshot for this comment.

This will generate the cropped part of the screenshot referenced by this comment and returns the HTML markup embedding it.

objects = <djblets.db.managers.ConcurrencyManager object>[source]
replies[source]
reply_to[source]
review[source]
screenshot[source]
set_extra_data_json(model_instance, json)[source]