reviewboard.attachments.forms¶
A form that handles uploading of new files.
- class UploadFileForm(review_request, *args, **kwargs)[source]¶
Bases:
Form
A form that handles uploading of new files.
- attachment_history[source]¶
An optional file attachment history.
This is used when creating a new revision for an existing file attachment. If this is not specified, a new history will be created.
- __init__(review_request, *args, **kwargs)[source]¶
Initialize the form.
- Parameters:
review_request (
reviewboard.reviews.models.ReviewRequest
) – The review request to attach the file to.args (
tuple
) – Extra positional arguments for the form.**kwargs (
dict
) – Extra keyword arguments for the form.
- clean_attachment_history()[source]¶
Validate that the specified file attachment history exists.
- Returns:
The history model.
- Return type:
- create(*, filediff: Optional[FileDiff] = None, from_modified: bool = True) FileAttachment [source]¶
Create a FileAttachment based on this form.
Changed in version 7.0:
Added the
from_modified
argument.Made arguments keyword-only.
- Parameters:
filediff (
reviewboard.diffviewer.models.filediff.FileDiff
, optional) – The optional diff to attach this file to (for use when this file represents a binary file within the diff).from_modified (
bool
, optional) –If creating an attachment for a FileDiff and this is
True
, create the attachment for the modified version of the file. Otherwise, create it for the source version of the file.New in version 7.0.
- Returns:
The new file attachment model.
- Return type:
- Raises:
reviewboard.attachments.errors.FileTooBigError – The file is too big for configured limits.
- __annotations__ = {}¶
- declared_fields = {'attachment_history': <django.forms.models.ModelChoiceField object>, 'caption': <django.forms.fields.CharField object>, 'extra_data': <djblets.db.fields.json_field.JSONFormField object>, 'path': <django.forms.fields.FileField object>}¶
- class UploadUserFileForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]¶
Bases:
Form
A form that handles uploading of user files.
- create(user, local_site=None)[source]¶
Create a FileAttachment based on this form.
- Parameters:
user (
django.contrib.auth.models.User
) – The user who owns this file attachment.local_site (
reviewboard.site.models.LocalSite
, optional) – The optional local site.
- Returns:
The new file attachment model.
- Return type:
- update(file_attachment)[source]¶
Update an existing file attachment.
- Parameters:
file_attachment (
reviewboard.attachments.models.FileAttachment
) – The file attachment to update.- Returns:
The updated file attachment.
- Return type:
- __annotations__ = {}¶
- declared_fields = {'caption': <django.forms.fields.CharField object>, 'extra_data': <djblets.db.fields.json_field.JSONFormField object>, 'path': <django.forms.fields.FileField object>}¶