Source code for apis_core.history.tables

import django_tables2 as tables

from apis_core.generic.tables import CustomTemplateColumn, ViewColumn


[docs] class DescriptionColumnHistory(CustomTemplateColumn): """ A column showing a model description """ template_name = "history/columns/description.html" orderable = False
[docs] class OriginalIDColumn(CustomTemplateColumn): """ A column showing the original id of a model instance """ template_name = "history/columns/original_id.html" orderable = False verbose_name = "Original ID"
[docs] class APISHistoryTableBaseTable(tables.Table): history_id = tables.Column(verbose_name="ID") original_id = OriginalIDColumn() desc = DescriptionColumnHistory() view = ViewColumn()
[docs] class Meta: fields = ["history_id", "desc", "most_recent", "view"]
[docs] class HistoryGenericTable(tables.Table): model = tables.Column(empty_values=()) fields_changed = tables.Column(empty_values=()) instance = tables.Column(linkify=lambda record: record.get_absolute_url()) fields_changed = tables.TemplateColumn( template_name="history/columns/fields_changed.html" )
[docs] class Meta: fields = [ "model", "instance", "tag", "fields_changed", "history_type", "history_date", "history_user", ]
[docs] def render_model(self, record): return record.instance.__class__.__name__