reviewboard.attachments.models¶
Models for file attachments and related objects.
- class FileAttachmentHistory(*args, **kwargs)[source]¶
Bases:
Model
Revision history for a single file attachment.
This tracks multiple revisions of the same file attachment (for instance, when someone replaces a screenshot with an updated version).
- display_position[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- latest_revision = <djblets.db.fields.relation_counter_field.RelationCounterField: latest_revision>[source]¶
- static compute_next_display_position(review_request)[source]¶
Compute the display position for a new FileAttachmentHistory.
- __annotations__ = {}¶
- decrement_latest_revision(*args, **kwargs)¶
- file_attachments¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- increment_latest_revision(*args, **kwargs)¶
- objects = <django.db.models.manager.Manager object>¶
- reinit_latest_revision()¶
- reload_latest_revision()¶
- review_request¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- class FileAttachment(*args, **kwargs)[source]¶
Bases:
Model
A file associated with a review request.
Like diffs, a file can have comments associated with it. These comments are of type
reviewboard.reviews.models.FileAttachmentComment
.A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- orig_filename[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- local_site[source]¶
The local site that this attachment is on.
This is only present for “user” file attachments (that is, attachments that were uploaded into a comment box or otherwise created from the user file attachments API). Attachments which are linked to a Review Request will not have this relation populated, and should instead use the Review Request’s local site. Callers should use the
get_local_site()
method instead of accessing this directly.
- uuid[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- file[source]¶
The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assign a file object on assignment so you can do:
>>> with open('/path/to/hello.world') as f: ... instance.file = File(f)
- mimetype[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- extra_data[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- repo_path[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- repo_revision[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- repository[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- added_in_filediff[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- attachment_history[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- attachment_revision[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects: ClassVar[FileAttachmentManager] = <reviewboard.attachments.managers.FileAttachmentManager object>¶
- get_local_site() Optional[LocalSite] [source]¶
Return the local site for this attachment.
New in version 7.0.3.
- Returns:
The local site that this attachment is related to, if any.
- Return type:
- get_raw_download_url() Optional[str] [source]¶
Return the absolute URL to download this file.
The URL will be determined by the storage backend. It may be accessible for only a limited amount of time, and may or may not be cacheable by the browser.
New in version 7.0.
- Returns:
The absolute URL to the file.
This will be
None
if there’s no file backing for any reason.- Return type:
- get_raw_thumbnail_image_url(*, width: Optional[int] = None, height: Optional[int] = None) Optional[str] [source]¶
Return the absolute URL for an image thumbnail for this file.
The URL will be determined by the storage backend. It may be accessible for only a limited amount of time, and may or may not be cacheable by the browser.
Not all file attachments support image thumbnails. If not supported, this will be
None
.New in version 7.0.
- Returns:
The absolute URL to the file.
This will be
None
if there’s no file backing for any reason, or if the attachment doesn’t support image thumbnails.- Return type:
- get_absolute_url() Optional[str] [source]¶
Return the absolute URL for accessing the file.
This will return the correct URL for either user-uploaded or review request file attachments.
If the association could not be determined, this will return
None
.The URL will always be a full absolute URL, usable in e-mails and other sources.
- Returns:
The URL to access the file attachment contents.
- Return type:
- is_review_ui_accessible_by(user: User) bool [source]¶
Return whether a user can access the file attachment’s review UI.
This will check that a review UI exists for the file attachment and that it’s enabled for the provided user and review request.
New in version 7.0.3.
- Parameters:
user (
django.contrib.auth.models.User
) – The user who is accessing the review UI.- Returns:
True
if a review UI exists and can be accessed by the user.False
if the review UI does not exist, cannot be used, or there’s an error when checking.- Return type:
- is_accessible_by(user)[source]¶
Returns whether or not the user has access to this FileAttachment.
This checks that the user has access to the LocalSite if the attachment is associated with a local site. This is only applicable for user owned file attachments.
- is_mutable_by(user)[source]¶
Returns whether or not a user can modify this FileAttachment.
This checks that the user is either a superuser or the owner of the file attachment. This is only applicable for user owned file attachments.
- __annotations__ = {'objects': 'ClassVar[FileAttachmentManager]'}¶
- added_in_filediff_id¶
- attachment_history_id¶
- comments¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- diffed_against_comments¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- drafts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- get_extra_data_json()¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- inactive_drafts¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- inactive_review_request¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- local_site_id¶
- repository_id¶
- review_request¶
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- set_extra_data_json(json)¶
- user_id¶
- get_latest_file_attachments(file_attachments: Sequence[FileAttachment]) List[FileAttachment] [source]¶
Filter the list of file attachments to only return the latest revisions.
- Parameters:
file_attachments (
list
of :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:`` :class:``reviewboard.attachments.models.FileAttachment
) – The file attachments to filter.- Returns:
The list of file attachments that are the latest revisions in their respective histories.
- Return type:
- FileAttachmentSequence¶
Type alias for a sequence of file attachments.
New in version 6.0.
alias of
Sequence
[FileAttachment
]