apis_core.history package

Subpackages

Submodules

apis_core.history.api_views module

class apis_core.history.api_views.EntityHistoryLogs(**kwargs)[source]

Bases: ListAPIView

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

serializer_class

alias of HistoryLogSerializer

class apis_core.history.api_views.GenericHistoryLog(**kwargs)[source]

Bases: RetrieveAPIView

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

serializer_class

alias of HistoryObjectSerializer

class apis_core.history.api_views.TempTripleHistoryLogs(**kwargs)[source]

Bases: ListAPIView

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

serializer_class

alias of HistoryLogSerializer

apis_core.history.apps module

class apis_core.history.apps.HistoryConfig(app_name, app_module)[source]

Bases: AppConfig

name = 'apis_core.history'

apis_core.history.models module

class apis_core.history.models.APISHistoricalRecords(verbose_name=None, verbose_name_plural=None, bases=(<class 'django.db.models.base.Model'>, ), user_related_name='+', table_name=None, inherit=False, excluded_fields=None, history_id_field=None, history_change_reason_field=None, user_model=None, get_user=<function _default_get_user>, cascade_delete_history=False, custom_model_name=None, app=None, history_user_id_field=None, history_user_getter=<function _history_user_getter>, history_user_setter=<function _history_user_setter>, related_name=None, use_base_model_db=False, user_db_constraint=True, no_db_index=[], excluded_field_kwargs=None, history_manager=<class 'simple_history.manager.HistoryManager'>, historical_queryset=<class 'simple_history.manager.HistoricalQuerySet'>, m2m_fields=(), m2m_fields_model_field_name='_history_m2m_fields', m2m_bases=(<class 'django.db.models.base.Model'>, ))[source]

Bases: HistoricalRecords, GenericModel

get_m2m_fields_from_model(model)[source]
get_prev_record()[source]

Get the previous history record for the instance. None if first.

class apis_core.history.models.APISHistoryTableBase(*args, **kwargs)[source]

Bases: Model, GenericModel

class Meta[source]

Bases: object

abstract = False
constraints = [<UniqueConstraint: fields=('id', Lower(F(version_tag))) name='id_version_tag_unique'>]
get_absolute_url()[source]
get_diff(other_version=None)[source]
get_triples_for_version(only_latest: bool = True, history_date: datetime = None, filter_for_triples: bool = True)[source]

returns all triples for a specific version of a model instance. If only_latest is True, only the latest version of a triple is returned.

set_version_tag(tag: str, include_triples: bool = True)[source]
version_tag

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class apis_core.history.models.VersionMixin(*args: Any, **kwargs: Any)[source]

Bases: Model

class Meta[source]

Bases: object

abstract = False
get_create_version_url()[source]
get_history_data()[source]
get_history_url()[source]
save_without_historical_record(*args, **kwargs)

Save model without saving a historical record

Make sure you know what you’re doing before you use this method.

apis_core.history.serializers module

class apis_core.history.serializers.HistoryLogSerializer(*args, **kwargs)[source]

Bases: Serializer

When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.

get_action(obj) str[source]
get_diff(obj)[source]
class apis_core.history.serializers.HistoryObjectSerializer(*args, **kwargs)[source]

Bases: Serializer

When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.

get_history(obj)[source]
get_instance(obj) str[source]
class apis_core.history.serializers.ModelChangeSerializer(*args, **kwargs)[source]

Bases: Serializer

When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.

get_data_for_m2m_field(value, field)[source]
get_field_data(obj, new: bool)[source]
get_field_data_new(obj)[source]
get_field_data_old(obj)[source]

apis_core.history.tables module

class apis_core.history.tables.APISHistoryTableBaseTable(data=None, order_by=None, orderable=None, empty_text=None, exclude=None, attrs=None, row_attrs=None, pinned_row_attrs=None, sequence=None, prefix=None, order_by_field=None, page_field=None, per_page_field=None, template_name=None, default=None, request=None, show_header=None, show_footer=True, extra_columns=None)[source]

Bases: Table

class Meta[source]

Bases: object

fields = ['history_id', 'desc', 'most_recent', 'view']
base_columns = {'desc': <apis_core.history.tables.DescriptionColumnHistory object>, 'history_id': <django_tables2.columns.base.Column object>, 'original_id': <apis_core.history.tables.OriginalIDColumn object>, 'view': <apis_core.generic.tables.ViewColumn object>}
class apis_core.history.tables.DescriptionColumnHistory(*args, **kwargs)[source]

Bases: CustomTemplateColumn

A column showing a model description

orderable = False
template_name = 'history/columns/description.html'
class apis_core.history.tables.HistoryGenericTable(data=None, order_by=None, orderable=None, empty_text=None, exclude=None, attrs=None, row_attrs=None, pinned_row_attrs=None, sequence=None, prefix=None, order_by_field=None, page_field=None, per_page_field=None, template_name=None, default=None, request=None, show_header=None, show_footer=True, extra_columns=None)[source]

Bases: Table

class Meta[source]

Bases: object

fields = ['model', 'instance', 'tag', 'fields_changed', 'history_type', 'history_date', 'history_user']
base_columns = {'fields_changed': <django_tables2.columns.templatecolumn.TemplateColumn object>, 'instance': <django_tables2.columns.base.Column object>, 'model': <django_tables2.columns.base.Column object>}
render_model(record)[source]
class apis_core.history.tables.OriginalIDColumn(*args, **kwargs)[source]

Bases: CustomTemplateColumn

A column showing the original id of a model instance

orderable = False
template_name = 'history/columns/original_id.html'
verbose_name = 'Original ID'

apis_core.history.urls module

apis_core.history.utils module

apis_core.history.utils.triple_sidebar_history(obj: object, request, detail=True)[source]

apis_core.history.views module

class apis_core.history.views.HistoryView(**kwargs)[source]

Bases: GenericModelMixin, SingleTableMixin, DetailView

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

get_table_class()[source]

Return the class to use for the table.

get_table_data()[source]

Return the table data that should be used to populate the rows.

template_name = 'history/history.html'
apis_core.history.views.create_new_version(request, contenttype, pk)[source]

Gets the version of the history instance and creates a new version.