Return null config params for tables with no model

This commit is contained in:
Jeremy Stretch 2025-04-08 14:53:25 -04:00
parent e6b2a03633
commit ca12f39c1a
3 changed files with 9 additions and 3 deletions

View File

@ -193,8 +193,10 @@ class BaseTable(tables.Table):
@property
def config_params(self):
if not (model := getattr(self.Meta, 'model', None)):
return None
return urlencode({
'object_type': ObjectType.objects.get_for_model(self.Meta.model).pk,
'object_type': ObjectType.objects.get_for_model(model).pk,
'table': self.name,
**self.configuration,
})

View File

@ -20,7 +20,9 @@
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
{# Include the updated "save" link for the table configuration #}
{% if table.config_params %}
<a class="dropdown-item" hx-swap-oob="outerHTML:#table_save_link" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
{% endif %}
{# Update the bulk action buttons with new query parameters #}
{% if actions %}

View File

@ -34,7 +34,9 @@
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
{% if table.config_params %}
<a class="dropdown-item" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
{% endif %}
{% if table_configs %}
<hr class="dropdown-divider">
{% for config in table_configs %}