reviewboard.reviews.views.diffviewer¶
Diff viewer view.
- class ReviewsDiffViewerContext[source]¶
Bases:
DiffViewerContext
,ReviewRequestContext
Render 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.
- __annotations__ = {'all_file_attachments': ForwardRef('list[FileAttachment]', module='reviewboard.reviews.views.diffviewer'), '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'), 'collapseall': ForwardRef('bool', module='reviewboard.diffviewer.views'), 'comments': ForwardRef('CommentsDict', module='reviewboard.reviews.views.diffviewer'), 'diff_context': ForwardRef('SerializedDiffContext', module='reviewboard.diffviewer.views'), 'diffset': ForwardRef('DiffSet', module='reviewboard.diffviewer.views'), 'diffsets': ForwardRef('list[DiffSet]', module='reviewboard.reviews.views.diffviewer'), 'draft': ForwardRef('Optional[ReviewRequestDraft]', module='reviewboard.reviews.views.diffviewer'), 'file_attachments': ForwardRef('list[FileAttachment]', module='reviewboard.reviews.views.diffviewer'), 'files': ForwardRef('list[SerializedDiffFile]', module='reviewboard.diffviewer.views'), 'force_view_user_draft': ForwardRef('bool', module='reviewboard.reviews.context'), 'interdiffset': ForwardRef('Optional[DiffSet]', module='reviewboard.diffviewer.views'), 'last_activity_time': ForwardRef('datetime', module='reviewboard.reviews.views.diffviewer'), 'mutable_by_user': ForwardRef('bool', module='reviewboard.reviews.context'), 'review': ForwardRef('Optional[Review]', module='reviewboard.reviews.views.diffviewer'), 'review_request': ForwardRef('ReviewRequest', module='reviewboard.reviews.context'), 'review_request_details': ForwardRef('Union[ReviewRequest, ReviewRequestDraft]', module='reviewboard.reviews.context'), 'review_request_status_html': ForwardRef('str', module='reviewboard.reviews.views.diffviewer'), 'review_request_visit': ForwardRef('NotRequired[ReviewRequestVisit]', module='reviewboard.reviews.context'), 'scmtool': ForwardRef('Optional[Tool]', module='reviewboard.reviews.context'), 'screenshots': ForwardRef('list[Screenshot]', module='reviewboard.reviews.views.diffviewer'), '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({'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({})¶
- __orig_bases__ = (<class 'reviewboard.diffviewer.views.DiffViewerContext'>, <class 'reviewboard.reviews.context.ReviewRequestContext'>)¶
- __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:
TypedDict
Serialized information about a diff with comments.
New in version 7.0.
- __annotations__ = {'is_current': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'revision': ForwardRef('int', module='reviewboard.reviews.views.diffviewer')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'is_current', 'revision'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'is_current', 'revision'})¶
- __total__ = True¶
- class SerializedInterdiffsetWithComments[source]¶
Bases:
TypedDict
Serialized information about an interdiff with comments.
New in version 7.0.
- __annotations__ = {'is_current': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'new_revision': ForwardRef('int', module='reviewboard.reviews.views.diffviewer'), 'old_revision': ForwardRef('int', module='reviewboard.reviews.views.diffviewer')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'is_current', 'new_revision', 'old_revision'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'is_current', 'new_revision', 'old_revision'})¶
- __total__ = True¶
- class SerializedCommitWithComments[source]¶
Bases:
TypedDict
Serialized information about a commit with comments.
New in version 7.0.
- __annotations__ = {'base_commit_id': ForwardRef('Optional[str]', module='reviewboard.reviews.views.diffviewer'), 'base_commit_pk': ForwardRef('Optional[int]', module='reviewboard.reviews.views.diffviewer'), 'is_current': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'revision': ForwardRef('int', module='reviewboard.reviews.views.diffviewer'), 'tip_commit_id': ForwardRef('Optional[str]', module='reviewboard.reviews.views.diffviewer'), 'tip_commit_pk': ForwardRef('Optional[int]', module='reviewboard.reviews.views.diffviewer')}¶
- __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({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __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:
TypedDict
Serialized 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.
- __annotations__ = {'commits_with_comments': ForwardRef('list[SerializedCommitWithComments]', module='reviewboard.reviews.views.diffviewer'), 'diffsets_with_comments': ForwardRef('list[SerializedDiffsetWithComments]', module='reviewboard.reviews.views.diffviewer'), 'has_other_comments': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'interdiffs_with_comments': ForwardRef('list[SerializedInterdiffsetWithComments]', module='reviewboard.reviews.views.diffviewer')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'commits_with_comments', 'diffsets_with_comments', 'has_other_comments', 'interdiffs_with_comments'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'commits_with_comments', 'diffsets_with_comments', 'has_other_comments', 'interdiffs_with_comments'})¶
- __total__ = True¶
- class SerializedReviewsDiffContext[source]¶
Bases:
SerializedDiffContext
Serialized 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.
- __annotations__ = {'comments_hint': ForwardRef('SerializedCommentsHint', module='reviewboard.reviews.views.diffviewer'), 'commit_history_diff': ForwardRef('Optional[list[SerializedCommitHistoryDiffEntry]]', module='reviewboard.diffviewer.views'), 'commits': ForwardRef('Optional[list[SerializedDiffCommit]]', module='reviewboard.diffviewer.views'), 'filename_patterns': ForwardRef('list[str]', module='reviewboard.diffviewer.views'), 'files': ForwardRef('list[SerializedReviewsDiffFile]', module='reviewboard.reviews.views.diffviewer'), 'num_diffs': ForwardRef('int', module='reviewboard.reviews.views.diffviewer'), 'pagination': ForwardRef('SerializedPaginationInfo', module='reviewboard.diffviewer.views'), 'revision': ForwardRef('SerializedRevisionInfo', module='reviewboard.diffviewer.views')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'comments_hint', 'commit_history_diff', 'commits', 'filename_patterns', 'files', 'num_diffs', 'pagination', 'revision'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<class 'reviewboard.diffviewer.views.SerializedDiffContext'>,)¶
- __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:
TypedDict
Serialized information about a FileDiff inside the diff files.
New in version 7.0.
- __annotations__ = {'id': ForwardRef('int', module='reviewboard.reviews.views.diffviewer'), 'revision': ForwardRef('int', module='reviewboard.reviews.views.diffviewer')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'id', 'revision'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'id', 'revision'})¶
- __total__ = True¶
- class SerializedReviewsDiffFile[source]¶
Bases:
TypedDict
Serialized information about a file in the diff.
New in version 7.0.
- 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.
- __annotations__ = {'base_filediff_id': ForwardRef('Optional[int]', module='reviewboard.reviews.views.diffviewer'), 'binary': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'deleted': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'filediff': ForwardRef('SerializedDiffFileFileDiff', module='reviewboard.reviews.views.diffviewer'), 'force_interdiff': ForwardRef('NotRequired[bool]', module='reviewboard.reviews.views.diffviewer'), 'id': ForwardRef('int', module='reviewboard.reviews.views.diffviewer'), 'index': ForwardRef('int', module='reviewboard.reviews.views.diffviewer'), 'interdiff_revision': ForwardRef('NotRequired[int]', module='reviewboard.reviews.views.diffviewer'), 'interfilediff': ForwardRef('NotRequired[SerializedDiffFileFileDiff]', module='reviewboard.reviews.views.diffviewer'), 'modified_filename': ForwardRef('str', module='reviewboard.reviews.views.diffviewer'), 'modified_revision': ForwardRef('str', module='reviewboard.reviews.views.diffviewer'), 'newfile': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'orig_filename': ForwardRef('str', module='reviewboard.reviews.views.diffviewer'), 'orig_revision': ForwardRef('str', module='reviewboard.reviews.views.diffviewer'), 'public': ForwardRef('bool', module='reviewboard.reviews.views.diffviewer'), 'serialized_comment_blocks': ForwardRef('SerializedCommentBlocks[SerializedDiffComment]', module='reviewboard.reviews.views.diffviewer')}¶
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'base_filediff_id', 'binary', 'deleted', 'filediff', 'force_interdiff', 'id', 'index', 'interdiff_revision', 'interfilediff', 'modified_filename', 'modified_revision', 'newfile', 'orig_filename', 'orig_revision', 'public', 'serialized_comment_blocks'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'base_filediff_id', 'binary', 'deleted', '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
,DiffViewerView
Renders the diff viewer for a review request.
This wraps the base
DiffViewerView
to 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_data
which 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:
- __annotations__ = {}¶