From 3ae7c3dcd2a644c2c559adbef8433090e5c552d9 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Fri, 23 Feb 2024 10:31:12 +0100 Subject: [PATCH] refactor(apis_relations): drop custom table factory This commit drops the `get_generic_triple_table` method that was used to generate the table classes for the triple tables in the edit and the detail view. For the edit and the detail view there are now the templatetags `triple_tables_related_detail` and `triple_tables_related_edit` which provide those tables. The `generic_order*` and `generic_render*` methods that were located in the `apis_metainfo.tables` module where dropped and replaced by custom table columns `StartDateColumn` and `EndDateColumn`. --- .../apis_entities/abstractentity_detail.html | 13 +- .../apis_entities/abstractentity_form.html | 6 +- .../entity_relations_multiple_cards.html | 29 +- .../templatetags/apis_templatetags.py | 23 +- apis_core/apis_metainfo/tables.py | 98 ------ apis_core/apis_relations/forms.py | 32 +- apis_core/apis_relations/tables.py | 301 +++++++++--------- .../templatetags/apis_relations.py | 51 +++ apis_core/utils/helpers.py | 47 +-- 9 files changed, 250 insertions(+), 350 deletions(-) create mode 100644 apis_core/apis_relations/templatetags/apis_relations.py diff --git a/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_detail.html b/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_detail.html index b8ce2083d..17a13edf9 100644 --- a/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_detail.html +++ b/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_detail.html @@ -1,6 +1,6 @@ {% extends "apis_core/apis_entities/abstractentity.html" %} {% load django_tables2 %} -{% load apis_templatetags %} +{% load apis_relations %} {% block col-zero %}
@@ -11,14 +11,9 @@ {% block col-one %}
- {% object_relations as object_relations %} - {% for rel in object_relations %} - - {% if rel.1.data|length > 0 %} -
{{ rel.0|title }}
-
{% render_table rel.1 %}
- {% endif %} - + {% for objecttype, table in object|triple_tables_related_detail %} +
{{ objecttype.name|title }}
+
{% render_table table %}
{% endfor %}
diff --git a/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html b/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html index a5a0e8073..d99e82e72 100644 --- a/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html +++ b/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html @@ -160,12 +160,10 @@ }) } - {% object_relations as object_relations %}