reviewboard.reviews.context¶
Methods to help with building the review request rendering context.
- class SerializedReviewRequestTab[source]¶
Bases:
TypedDict
Serialized information about a tab on the review request page.
New in version 7.0.
- __annotations__ = {'active': ForwardRef('NotRequired[bool]', module='reviewboard.reviews.context'), 'text': ForwardRef('str', module='reviewboard.reviews.context'), 'url': ForwardRef('str', module='reviewboard.reviews.context')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'active', 'text', 'url'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'active', 'text', 'url'})¶
- __total__ = True¶
- class ReviewRequestContext[source]¶
Bases:
TypedDict
Template context for rendering the review request.
Changed in version 7.0.2: Added the following fields:
close_description
close_description_rich_text
close_timestamp
draft
force_view_user_draft
review_request_details
user_draft_exists
viewing_user_draft
New in version 7.0.
- close_description_rich_text: bool¶
Whether the close description is rich text.
New in version 7.0.2.
- close_timestamp: Optional[datetime]¶
The timestamp of the most recent closing.
New in version 7.0.2.
- draft: Optional[ReviewRequestDraft]¶
The current draft, if present.
New in version 7.0.2.
- force_view_user_draft: bool¶
Whether to force viewing a draft owned by another user.
New in version 7.0.2.
- review_request: ReviewRequest¶
The review request object.
- review_request_details: Union[ReviewRequest, ReviewRequestDraft]¶
The current object to use for displaying the review request data.
New in version 7.0.2.
- review_request_visit: NotRequired[ReviewRequestVisit]¶
The most recent review request visit info, if available.
- tabs: list[SerializedReviewRequestTab]¶
The tabs to show for the review request.
- user_draft_exists: bool¶
Whether a draft exists that is owned by another user.
New in version 7.0.2.
- viewing_user_draft: bool¶
Whether the user is viewing a draft owned by another user.
New in version 7.0.2.
- __annotations__ = {'close_description': ForwardRef('str', module='reviewboard.reviews.context'), 'close_description_rich_text': ForwardRef('bool', module='reviewboard.reviews.context'), 'close_timestamp': ForwardRef('Optional[datetime]', module='reviewboard.reviews.context'), 'draft': ForwardRef('Optional[ReviewRequestDraft]', module='reviewboard.reviews.context'), 'force_view_user_draft': ForwardRef('bool', module='reviewboard.reviews.context'), 'mutable_by_user': ForwardRef('bool', module='reviewboard.reviews.context'), 'review_request': ForwardRef('ReviewRequest', module='reviewboard.reviews.context'), 'review_request_details': ForwardRef('Union[ReviewRequest, ReviewRequestDraft]', module='reviewboard.reviews.context'), 'review_request_visit': ForwardRef('NotRequired[ReviewRequestVisit]', module='reviewboard.reviews.context'), 'scmtool': ForwardRef('Optional[Tool]', module='reviewboard.reviews.context'), 'send_email': ForwardRef('bool', module='reviewboard.reviews.context'), 'social_page_description': ForwardRef('str', module='reviewboard.reviews.context'), 'social_page_image_url': ForwardRef('Optional[str]', module='reviewboard.reviews.context'), 'social_page_title': ForwardRef('str', module='reviewboard.reviews.context'), 'social_page_url': ForwardRef('str', module='reviewboard.reviews.context'), 'status_mutable_by_user': ForwardRef('bool', module='reviewboard.reviews.context'), 'tabs': ForwardRef('list[SerializedReviewRequestTab]', module='reviewboard.reviews.context'), 'user_draft_exists': ForwardRef('bool', module='reviewboard.reviews.context'), 'viewing_user_draft': ForwardRef('bool', module='reviewboard.reviews.context')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'close_description', 'close_description_rich_text', 'close_timestamp', 'draft', 'force_view_user_draft', 'mutable_by_user', 'review_request', 'review_request_details', 'review_request_visit', 'scmtool', 'send_email', 'social_page_description', 'social_page_image_url', 'social_page_title', 'social_page_url', 'status_mutable_by_user', 'tabs', 'user_draft_exists', 'viewing_user_draft'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'close_description', 'close_description_rich_text', 'close_timestamp', 'draft', 'force_view_user_draft', 'mutable_by_user', 'review_request', 'review_request_details', 'review_request_visit', 'scmtool', 'send_email', 'social_page_description', 'social_page_image_url', 'social_page_title', 'social_page_url', 'status_mutable_by_user', 'tabs', 'user_draft_exists', 'viewing_user_draft'})¶
- __total__ = True¶
- make_review_request_context(*, request: HttpRequest, review_request: ReviewRequest, extra_context: Optional[dict[str, Any]] = None, is_diff_view: bool = False, social_page_image_url: Optional[str] = None, social_page_title: str = '', review_request_details: Optional[Union[ReviewRequest, ReviewRequestDraft]] = None, close_info: Optional[ReviewRequestCloseInfo] = None, draft: Optional[ReviewRequestDraft] = None, force_view_user_draft: bool = False) ReviewRequestContext [source]¶
Return a dictionary for template contexts used for review requests.
The dictionary will contain the common data that is used for all review request-related pages (the review request detail page, the diff viewer, and the screenshot pages).
For convenience, extra data can be passed to this dictionary.
Changed in version 7.0.2:
Deprecated the
extra_context
argument.Added the
review_request_details
,close_info
,draft
andforce_view_user_draft
arguments.
Changed in version 7.0: Added
social_page_image_url
andsocial_page_title
arguments.- Parameters:
request (
django.http.HttpRequest
) – The HTTP request.review_request (
reviewboard.reviews.models.ReviewRequest
) – The review request.extra_context (
dict
, optional) – Extra information to include in the context.is_diff_view (
bool
, optional) – Whether the user is viewing a diff.social_page_image_url (
str
, optional) –The image URL to include for social media thumbnails.
New in version 7.0.
social_page_title (
str
, optional) –The page title to include for social media thumbnails.
New in version 7.0.
review_request_details (
reviewboard.reviews.models.ReviewRequest
or :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:``reviewboard.reviews.models.ReviewRequestDraft
) –The object to show review request content from.
New in version 7.0.
close_info (
reviewboard.reviews.models.review_request.ReviewRequestCloseInfo
, optional) –Close information about the review request.
New in version 7.0.2.
draft (
reviewboard.reviews.models.ReviewRequestDraft
, optional) –The review request draft.
New in version 7.0.2.
force_view_user_draft (
bool
, optional) –Whether to force viewing another user’s draft.
This is used when a user with privilege to view other users’ draft data is viewing something which only exists in the draft (such as an unpublished review request or a file attachment added in a new draft).
New in version 7.0.2.
- Returns:
The context for rendering review request templates.
- Return type:
- should_view_draft(*, request: HttpRequest, review_request: ReviewRequest, draft: Optional[ReviewRequestDraft]) bool [source]¶
Return whether the requesting user should view the draft.
- Parameters:
request (
django.http.HttpRequest
) – The HTTP request.review_request (
reviewboard.reviews.models.ReviewRequest
) – The current review request.draft (
reviewboard.reviews.models.ReviewRequestDraft
) – The current review request draft.
- Returns:
True
if the user should view the draft data.- Return type: