From 6fcb2e0ddda0b0fc36911f589665949cba2b3809 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Thu, 9 Nov 2023 13:08:31 +0100 Subject: [PATCH] fix: provide a way to override an entities list table Closes: #400 --- apis_core/apis_entities/tables.py | 5 +++-- docs/source/configuration.rst | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apis_core/apis_entities/tables.py b/apis_core/apis_entities/tables.py index fdc870089..ceb34c239 100644 --- a/apis_core/apis_entities/tables.py +++ b/apis_core/apis_entities/tables.py @@ -1,7 +1,7 @@ import django_tables2 as tables from django.utils.safestring import mark_safe from django_tables2.utils import A -from apis_core.utils.settings import list_links_to_edit +from apis_core.utils.settings import list_links_to_edit, get_entity_settings_by_modelname from apis_core.apis_metainfo.tables import ( generic_order_start_date_written, @@ -69,4 +69,5 @@ class Meta: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - return GenericEntitiesTable + entity_settings = get_entity_settings_by_modelname(entity) + return entity_settings.get("table", GenericEntitiesTable) diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index dbceae662..9e498ea37 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -201,6 +201,7 @@ allows to merge several entities in one target entity at once. ``form_order`` defines the order of the fields in the metadata form of the respective entity. ``form`` allows you to set a custom form for the entity, instead of the default `apis_entities.forms.GenericEntityForm` ``table_fields`` sets the default columns to show in the list views. +``table`` allows you to set a custom table class for the list view of the entity, instead of the default :class:`apis_core.apis_entities.tables.get_entities_table.GenericEntitiesTable` ``additional_cols`` allows to set the columns that user can add to the result view. ``relations_per_page`` allows to set the number of relations listed before pagination begins ``detail_view_exclude`` allows to set fields that are excluded from the default detail view