Jump to >

reviewboard.reviews.managers

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

A manager for DefaultReviewer models.

for_repository(repository, local_site)[source]

Returns all DefaultReviewers that represent a repository.

These include both DefaultReviewers that have no repositories (for backwards-compatibility) and DefaultReviewers that are associated with the given repository.

can_create(user, local_site=None)[source]

Returns whether the user can create default reviewers.

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

A manager for Group models.

accessible(user, visible_only=True, local_site=None, show_all_local_sites=False, distinct=True)[source]

Return a queryset for review groups accessible by the given user.

For superusers, all public and invite-only review groups will be returned.

For regular users, only review groups that are public or that the user is on the access list for will be returned.

For anonymous users, only public review groups will be returned.

The returned list is further filtered down based on the visible_only, local_site, and show_all_local_sites parameters.

Changed in version 3.0.24: Added the distinct parameter.

Parameters
  • user (django.contrib.auth.models.User) – The user that must have access to any returned groups.

  • visible_only (bool, optional) – Whether only visible review groups should be returned.

  • local_site (reviewboard.site.models.LocalSite, optional) – A specific Local Site that the groups must be associated with. By default, this will only return groups not part of a site.

  • show_all_local_sites (bool, optional) – Whether review groups for all Local Sites should be returned. This cannot be True if a local_site argument was provided.

  • distinct (bool, optional) –

    Whether to return distinct results.

    Turning this off can increase performance. It’s on by default for backwards-compatibility.

Returns

The resulting queryset.

Return type

django.db.models.query.QuerySet

accessible_ids(*args, **kwargs)[source]

Return IDs of groups that are accessible by the given user.

This wraps accessible() and takes the same arguments (with the exception of distinct, which is ignored).

Changed in version 3.0.24: In prior versions, the order was not specified, but was generally numeric order. This should still be true, but officially, we no longer guarantee any order of results.

Parameters
Returns

The list of IDs.

Return type

list of int

can_create(user, local_site=None)[source]

Returns whether the user can create groups.

class ReviewRequestQuerySet(model=None, query=None, using=None, hints=None)[source]
class ReviewRequestManager(*args, **kwargs)[source]

A manager for review requests. Provides specialized queries to retrieve review requests with specific targets or origins, and to create review requests based on certain data.

get_queryset()[source]

Return a QuerySet for ReviewRequest models.

Returns

The new QuerySet instance.

Return type

ReviewRequestQuerySet

create(user, repository, commit_id=None, local_site=None, create_from_commit_id=False, create_with_history=False)[source]

Create a new review request.

Parameters
  • user (django.contrib.auth.models.User) – The user creating the review request. They will be tracked as the submitter.

  • repository (reviewboard.scmtools.Models.Repository) –

    The repository, if any, the review request is associated with.

    If None, diffs cannot be added to the review request.

  • commit_id (unicode, optional) – An optional commit ID.

  • local_site (reviewboard.site.models.LocalSite, optional) – An optional LocalSite to associate the review request with.

  • create_from_commit_id (bool, optional) – Whether or not the given commit_id should be used to pre-populate the review request data. If True, the given repository will be used to do so.

  • create_with_history (bool, optional) –

    Whether or not the created review request will support attaching multiple commits per diff revision.

    If False, it will not be possible to use the DiffResource to upload diffs; the DiffCommitResource must be used instead.

Returns

The created review request.

Return type

reviewboard.reviews.models.review_request.ReviewRequest

Raises
get_to_group_query(group_name, local_site)[source]

Returns the query targetting a group.

This is meant to be passed as an extra_query to ReviewRequest.objects.public().

get_to_user_groups_query(user_or_username)[source]

Returns the query targetting groups joined by a user.

This is meant to be passed as an extra_query to ReviewRequest.objects.public().

get_to_user_directly_query(user_or_username)[source]

Returns the query targetting a user directly.

This will include review requests where the user has been listed as a reviewer, or the user has starred.

This is meant to be passed as an extra_query to ReviewRequest.objects.public().

get_to_user_query(user_or_username)[source]

Returns the query targetting a user indirectly.

This will include review requests where the user has been listed as a reviewer, or a group that the user belongs to has been listed, or the user has starred.

This is meant to be passed as an extra_query to ReviewRequest.objects.public().

get_from_user_query(user_or_username)[source]

Returns the query for review requests created by a user.

This is meant to be passed as an extra_query to ReviewRequest.objects.public().

get_to_or_from_user_query(user_or_username)[source]

Return the query for review requests a user is involved in.

This is meant to be passed as an extra_query to ReviewRequest.objects.public.

Parameters

user_or_username (django.contrib.auth.models.User or unicode) – The user object or username to query for.

Returns

A query for all review requests the users is involved in as either a submitter or a reviewer (either directly assigned or indirectly as a member of a group).

Return type

django.db.models.Q

to_or_from_user(user_or_username, *args, **kwargs)[source]

Return the Queryset for review requests a user is involved in.

Parameters
  • user_or_username (django.contrib.auth.models.User or unicode) – The user object or username to query for.

  • *args (tuple) – Extra postional arguments passed into handler.

  • **kwargs (dict) – Extra keyword arguments passed into handler.

Returns

A queryset of all review requests the users is involved in as either a submitter or a reviewer (either directly assigned or indirectly as a member of a group).

Return type

django.db.models.query.QuerySet

for_id(pk, local_site=None)[source]

Returns the review request matching the given ID and LocalSite.

If a LocalSite is provided, then the ID will be matched against the displayed ID for the LocalSite, rather than the in-database ID.

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

A manager for Review models.

This handles concurrency issues with Review models. In particular, it will try hard not to save two reviews at the same time, and if it does manage to do that (which may happen for pending reviews while a server is under heavy load), it will repair and consolidate the reviews on load. This prevents errors and lost data.

get_pending_review(review_request, user)[source]

Return a user’s pending review on a review request.

This will handle fixing duplicate reviews if more than one pending review is found.

Parameters
Returns

The pending review object.

Return type

reviewboard.reviews.models.review.Review

get_pending_reply(review, user)[source]

Return a user’s pending reply to a given review.

This will handle fixing duplicate reviews if more than one pending review reply is found.

Parameters
Returns

The pending review object.

Return type

reviewboard.reviews.models.review.Review

fix_duplicate_reviews(reviews)[source]

Fix duplicate reviews, condensing them into a single review.

This will consolidate the data from all reviews into the first review in the list, and return the first review.

from_user(user_or_username, *args, **kwargs)[source]

Return the query for reviews created by a user.

Parameters

user_or_username (django.contrib.auth.models.User or unicode) – The user object or username to query for.

Returns

A queryset for all the reviews created by the given user.

Return type

django.db.models.query.QuerySet