Jump to >

reviewboard.attachments.forms

class UploadFileForm(review_request, *args, **kwargs)[source]

Bases: django.forms.forms.Form

A form that handles uploading of new files.

caption = None

The caption for the file.

path = None

The file itself.

attachment_history = None

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:
clean_attachment_history()[source]

Validate that the specified file attachment history exists.

Returns:The history model.
Return type:reviewboard.attachments.models.FileAttachmentHistory
create(filediff=None)[source]

Create a FileAttachment based on this form.

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).
Returns:The new file attachment model.
Return type:reviewboard.attachments.models.FileAttachment
declared_fields = {'attachment_history': <django.forms.models.ModelChoiceField object>, 'caption': <django.forms.fields.CharField object>, 'path': <django.forms.fields.FileField object>}[source]
class UploadUserFileForm(data=None, files=None, auto_id=u'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: django.forms.forms.Form

A form that handles uploading of user files.

caption = None

The caption for the file.

path = None

The file itself.

create(user, local_site=None)[source]

Create a FileAttachment based on this form.

Parameters:
Returns:

The new file attachment model.

Return type:

reviewboard.attachments.models.FileAttachment

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:reviewboard.attachments.models.FileAttachment
declared_fields = {'caption': <django.forms.fields.CharField object>, 'path': <django.forms.fields.FileField object>}[source]
get_unique_filename(filename)[source]

Return a unique filename.

Create a unique filename by concatenating a UUID with the given filename.

Parameters:filename (unicode) – The original filename.
Returns:A new filename which is more unique.
Return type:unicode