reviewboard.reviews.views.diffviewer¶
Diff viewer view.
- class ReviewsDiffViewerContext[source]¶
Bases:
DiffViewerContext,ReviewRequestContextRender context for the diff viewer view.
New in version 7.0.
- draft: Optional[ReviewRequestDraft]¶
The draft of the review request, if present.
- last_activity_time: datetime¶
The timestamp of the last activity.
- file_attachments: list[FileAttachment]¶
The current set of file attachments for the review request.
- all_file_attachments: list[FileAttachment]¶
All of the file attachments for the review request.
This includes all current attachments, as well as old versions and files that have been removed.
- screenshots: list[Screenshot]¶
The screenshots attached to the review request.
This is a legacy item which has been replaced by the file attachments.
- comments: CommentsDict¶
All of the diff comments for the review request.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'all_file_attachments', 'close_description', 'close_description_rich_text', 'close_timestamp', 'collapseall', 'comments', 'diff_context', 'diffset', 'diffsets', 'draft', 'file_attachments', 'files', 'force_view_user_draft', 'interdiffset', 'last_activity_time', 'mutable_by_user', 'review', 'review_request', 'review_request_details', 'review_request_status_html', 'review_request_visit', 'scmtool', 'screenshots', '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({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'all_file_attachments', 'close_description', 'close_description_rich_text', 'close_timestamp', 'collapseall', 'comments', 'diff_context', 'diffset', 'diffsets', 'draft', 'file_attachments', 'files', 'force_view_user_draft', 'interdiffset', 'last_activity_time', 'mutable_by_user', 'review', 'review_request', 'review_request_details', 'review_request_status_html', 'review_request_visit', 'scmtool', 'screenshots', '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¶
- diff_context: SerializedDiffContext¶
- files: list[SerializedDiffFile]¶
- close_timestamp: Optional[datetime]¶
- review_request: ReviewRequest¶
- review_request_details: Union[ReviewRequest, ReviewRequestDraft]¶
- review_request_visit: NotRequired[ReviewRequestVisit]¶
- tabs: list[SerializedReviewRequestTab]¶
- class SerializedDiffsetWithComments[source]¶
Bases:
TypedDictSerialized information about a diff with comments.
New in version 7.0.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'is_current', 'revision'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'is_current', 'revision'})¶
- __total__ = True¶
- class SerializedInterdiffsetWithComments[source]¶
Bases:
TypedDictSerialized information about an interdiff with comments.
New in version 7.0.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'is_current', 'new_revision', 'old_revision'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'is_current', 'new_revision', 'old_revision'})¶
- __total__ = True¶
- class SerializedCommitWithComments[source]¶
Bases:
TypedDictSerialized information about a commit with comments.
New in version 7.0.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'base_commit_id', 'base_commit_pk', 'is_current', 'revision', 'tip_commit_id', 'tip_commit_pk'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'base_commit_id', 'base_commit_pk', 'is_current', 'revision', 'tip_commit_id', 'tip_commit_pk'})¶
- __total__ = True¶
- class SerializedCommentsHint[source]¶
Bases:
TypedDictSerialized information about comments in other revisions.
New in version 7.0.
- commits_with_comments: list[SerializedCommitWithComments]¶
The set of commit ranges that have draft comments.
- diffsets_with_comments: list[SerializedDiffsetWithComments]¶
The set of diffs that have draft comments.
- interdiffs_with_comments: list[SerializedInterdiffsetWithComments]¶
The set of interdiffs that have draft comments.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'commits_with_comments', 'diffsets_with_comments', 'has_other_comments', 'interdiffs_with_comments'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'commits_with_comments', 'diffsets_with_comments', 'has_other_comments', 'interdiffs_with_comments'})¶
- __total__ = True¶
- class SerializedReviewsDiffContext[source]¶
Bases:
SerializedDiffContextSerialized diff context information.
New in version 7.0.
- comments_hint: SerializedCommentsHint¶
The hint to show for draft reviews with comments in other revisions.
- files: list[SerializedReviewsDiffFile]¶
The list of files in the current diff view.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'comments_hint', 'commit_history_diff', 'commits', 'filename_patterns', 'files', 'num_diffs', 'pagination', 'revision'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'comments_hint', 'commit_history_diff', 'commits', 'filename_patterns', 'files', 'num_diffs', 'pagination', 'revision'})¶
- __total__ = True¶
- commits: Optional[list[SerializedDiffCommit]]¶
- pagination: SerializedPaginationInfo¶
- revision: SerializedRevisionInfo¶
- class SerializedDiffFileFileDiff[source]¶
Bases:
TypedDictSerialized information about a FileDiff inside the diff files.
New in version 7.0.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'id', 'revision'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'id', 'revision'})¶
- __total__ = True¶
- class SerializedReviewsDiffFile[source]¶
Bases:
TypedDictSerialized information about a file in the diff.
New in version 7.0.
- extra: DiffFileExtraContext¶
Extra information about the diff file.
New in version 7.0.4.
- interfilediff: NotRequired[SerializedDiffFileFileDiff]¶
Information about the interdiff FileDiff, when present.
- filediff: SerializedDiffFileFileDiff¶
Information about the FileDiff.
- force_interdiff: NotRequired[bool]¶
Whether to force rendering an interdiff.
This is used to ensure that reverted files render correctly.
- serialized_comment_blocks: SerializedCommentBlocks[SerializedDiffComment]¶
The serialized comments already attached to the file’s diff.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'base_filediff_id', 'binary', 'deleted', 'extra', 'filediff', 'force_interdiff', 'id', 'index', 'interdiff_revision', 'interfilediff', 'modified_filename', 'modified_revision', 'newfile', 'orig_filename', 'orig_revision', 'public', 'serialized_comment_blocks'})¶
- __optional_keys__ = frozenset({})¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'base_filediff_id', 'binary', 'deleted', 'extra', 'filediff', 'force_interdiff', 'id', 'index', 'interdiff_revision', 'interfilediff', 'modified_filename', 'modified_revision', 'newfile', 'orig_filename', 'orig_revision', 'public', 'serialized_comment_blocks'})¶
- __total__ = True¶
- class ReviewsDiffViewerView(**kwargs)[source]¶
Bases:
ReviewRequestViewMixin,UserProfileRequiredViewMixin,DiffViewerViewRenders the diff viewer for a review request.
This wraps the base
DiffViewerViewto display a diff for the given review request and the given diff revision or range.The view expects the following parameters to be provided:
review_request_id:The ID of the ReviewRequest containing the diff to render.
The following may also be provided:
revision:The DiffSet revision to render.
interdiff_revision:The second DiffSet revision in an interdiff revision range.
local_site:The LocalSite the ReviewRequest must be on, if any.
See
DiffViewerView’s documentation for the accepted query parameters.- __init__(**kwargs) None[source]¶
Initialize a view for the request.
- Parameters:
**kwargs (
dict) – Keyword arguments passed toas_view().
- get(request: HttpRequest, revision: Optional[int] = None, interdiff_revision: Optional[int] = None, *args, **kwargs) HttpResponse[source]¶
Handle HTTP GET requests for this view.
This will look up the review request and DiffSets, given the provided information, and pass them to the parent class for rendering.
- Parameters:
request (
django.http.HttpRequest) – The HTTP request from the client.revision (
int, optional) – The revision of the diff to view. This defaults to the latest diff.interdiff_revision (
int, optional) – The revision to use for an interdiff, if viewing an interdiff.*args (
tuple) – Positional arguments passed to the handler.**kwargs (
dict) – Keyword arguments passed to the handler.
- Returns:
The HTTP response to send to the client.
- Return type:
- get_context_data(diffset: DiffSet, interdiffset: Optional[DiffSet], **kwargs) ReviewsDiffViewerContext[source]¶
Return additional context data for the template.
This provides some additional data used for rendering the diff viewer. This data is more specific to the reviewing functionality, as opposed to the data calculated by
DiffViewerView.get_context_datawhich is more focused on the actual diff.- Parameters:
diffset (
reviewboard.diffviewer.models.DiffSet) – The diffset being viewed.interdiffset (
reviewboard.diffviewer.models.DiffSet) – The interdiff diffset, if present.**kwargs (
dict) – Keyword arguments passed to the handler.
- Returns:
Context data used to render the template.
- Return type: