adminjournal.entry module

class adminjournal.entry.Entry(action, user, model_class=None, model=None, description=None, timestamp=None, payload=None)[source]

Bases: object

This class represents a journal entry and provides methods to get information about the action which was tracked.

ACTION_VIEW = 'view'[source]
ACTION_ADD = 'add'[source]
ACTION_CHANGE = 'change'[source]
ACTION_DELETE = 'delete'[source]
__init__(action, user, model_class=None, model=None, description=None, timestamp=None, payload=None)[source]

Create a new entry instance.

The constructor handles the provided data and does some basis validation.

The parameters action and user are always required. It is possible to override the timestamp which used for that event.

In addition, model_class and/or model needs to be provided. If both are given, the constructor will ensure that the model_class fits the provided model.

It is allowed to provide one of the following as model_class:
  • Python class of a Django model
  • ContentType model instance
  • None (if none is provided, the model_class will be derived from the given model).

You don’t have to provide a model if you already have the model_class on hand.

The parameter description is useful to provide a human-readable representation of what happened.

timestamp = None[source]

Point in time when the event happend.

payload = None[source]

Dict-like object holding any other information related to the event.

user_repr[source]

Returns a human readable version of the user object.

content_type_repr[source]

Returns a human readable version of the content type object.

object_id[source]
persist()[source]

Triggers the persisting of the instance.