Jump to >

reviewboard.diffviewer.forms

Forms for uploading diffs.

class BaseCommitValidationForm(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 mixin for handling validation metadata for commits.

clean_validation_info()[source]

Clean the validation_info field.

This method ensures that if the field is supplied that it parses as base64-encoded JSON.

Returns:The parsed validation information.
Return type:dict
Raises:django.core.exceptions.ValidationError – The value could not be parsed.
declared_fields = {'validation_info': <django.forms.fields.CharField object>}[source]
class UploadCommitForm(diffset, request=None, *args, **kwargs)[source]

Bases: reviewboard.diffviewer.forms.BaseCommitValidationForm

The form for uploading a diff and creating a DiffCommit.

__init__(diffset, request=None, *args, **kwargs)[source]

Initialize the form.

Parameters:
create()[source]

Create the DiffCommit.

Returns:The created DiffCommit.
Return type:reviewboard.diffviewer.models.diffcommit.DiffCommit
clean()[source]

Clean the form.

Returns:The cleaned form data.
Return type:dict
Raises:django.core.exceptions.ValidationError – The form data was not valid.
clean_author_date()[source]

Parse the date and time in the author_date field.

Returns:The parsed date and time.
Return type:datetime.datetime
clean_committer_date()[source]

Parse the date and time in the committer_date field.

Returns:The parsed date and time.
Return type:datetime.datetime
declared_fields = {'author_date': <django.forms.fields.CharField object>, 'author_email': <django.forms.fields.CharField object>, 'author_name': <django.forms.fields.CharField object>, 'commit_id': <django.forms.fields.CharField object>, 'commit_message': <django.forms.fields.CharField object>, 'committer_date': <django.forms.fields.CharField object>, 'committer_email': <django.forms.fields.CharField object>, 'committer_name': <django.forms.fields.CharField object>, 'diff': <django.forms.fields.FileField object>, 'parent_diff': <django.forms.fields.FileField object>, 'parent_id': <django.forms.fields.CharField object>, 'validation_info': <django.forms.fields.CharField object>}[source]
class UploadDiffForm(repository, request=None, *args, **kwargs)[source]

Bases: django.forms.forms.Form

The form for uploading a diff and creating a DiffSet.

__init__(repository, request=None, *args, **kwargs)[source]

Initialize the form.

Parameters:
clean_base_commit_id()[source]

Clean the base_commit_id field.

Returns:The base_commit_id field stripped of leading and trailing whitespace, or None if that value would be empty.
Return type:unicode
clean_basedir()[source]

Clean the basedir field.

Returns:The basedir field as a unicode string with leading and trailing whitespace removed.
Return type:unicode
create(diffset_history=None)[source]

Create the DiffSet.

Parameters:diffset_history (reviewboard.diffviewer.models.diffset_history.DiffSetHistory) – The DiffSet history to attach the created DiffSet to.
Returns:The created DiffSet.
Return type:reviewboard.diffviewer.models.diffset.DiffSet
declared_fields = {'base_commit_id': <django.forms.fields.CharField object>, 'basedir': <django.forms.fields.CharField object>, 'parent_diff_path': <django.forms.fields.FileField object>, 'path': <django.forms.fields.FileField object>}[source]
class ValidateCommitForm(repository, request=None, *args, **kwargs)[source]

Bases: reviewboard.diffviewer.forms.BaseCommitValidationForm

A form for validating of DiffCommits.

__init__(repository, request=None, *args, **kwargs)[source]

Initialize the form.

Parameters:
  • repository (reviewboard.scmtools.models.Repository) – The repository against which the diff is being validated.
  • request (django.http.HttpRequest, optional) – The HTTP request from the client.
  • *args (tuple) – Additional positional arguments to pass to the base class initializer.
  • **kwargs (dict) – Additional keyword arguments to pass to the base class initializer.
clean()[source]

Clean the form.

Returns:The cleaned form data.
Return type:dict
Raises:django.core.exceptions.ValidationError – The form data was not valid.
validate_diff()[source]

Validate the DiffCommit.

This will attempt to parse the given diff (and optionally parent diff) into FileDiffs. This will not result in anything being committed to the database.

Returns:

A 2-tuple containing the following:

  • A list of the created FileDiffs.
  • A list of the parent FileDiffs, or None.

Return type:

tuple

Raises:
declared_fields = {'base_commit_id': <django.forms.fields.CharField object>, 'commit_id': <django.forms.fields.CharField object>, 'diff': <django.forms.fields.FileField object>, 'parent_diff': <django.forms.fields.FileField object>, 'parent_id': <django.forms.fields.CharField object>, 'validation_info': <django.forms.fields.CharField object>}[source]