Jump to >

reviewboard.changedescs.models

class ChangeDescription(*args, **kwargs)[source]

Bases: django.db.models.base.Model

The recorded set of changes, with a description and the changed fields.

This is a general model that can be used in applications for recording changes how they see fit. A helper function, ‘record_field_changed’, can be used to record information in a standard way for most value types, but the ‘fields_changed’ dictionary can be manipulated however the caller chooses.

A ChangeDescription is not bound to a particular model. It is up to models to establish relationships with a ChangeDescription.

Each field in ‘fields_changed’ represents a changed field.

For string fields, the following fields will be available:

  • ‘old’: The old value of the field
  • ‘new’: The new value of the field

For list and set fields, the following fields will be available:

  • ‘removed’: The fields that were removed, if any.
  • ‘added’: The fields that were added, if any.
record_field_change(field, old_value, new_value, name_field=None)[source]

Record a field change.

This will encode field changes following the rules in the overlying ‘ChangeDescription’ documentation.

‘name_field’ can be specified for lists or other iterables. When specified, each list item will be a tuple in the form of (object_name, object_url, object_id). Otherwise, it will be a tuple in the form of (item,).

It is generally expected that fields with lists of model objects will have ‘name_field’ set, whereas lists of numbers or some other value type will not. Specifying a ‘name_field’ for non-objects will cause an AttributeError.

__str__()[source]
has_modified_fields()[source]

Determine if the ‘fields_changed’ variable is non-empty.

Uses the ‘fields_changed’ variable to determine if there are any current modifications being tracked to this ChangedDescription object.

__unicode__()[source]

Return a string representation of the object.

get_fields_changed_json(model_instance)[source]
get_next_by_timestamp(*moreargs, **morekwargs)[source]
get_previous_by_timestamp(*moreargs, **morekwargs)[source]
objects = <django.db.models.manager.Manager object>[source]
review_request[source]
reviewrequestdraft_set[source]
set_fields_changed_json(model_instance, json)[source]