From efdcaf9911a87fd2551d110d6ab1359a5c7e6a61 Mon Sep 17 00:00:00 2001 From: Jan Krupa Date: Tue, 12 May 2026 11:11:37 +0200 Subject: [PATCH 1/6] Add Add-button on Typed tabs with reverse-reference prefill (closes #9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each Typed tab now shows an "Add " button in the bottom toolbar (alongside Bulk Edit and Bulk Delete) that opens the native customobject_add view with the reverse-reference field pre-filled to the parent object's PK and return_url set back to the tab. After saving, the user lands back on the same tab, with any active filters preserved. When a Custom Object Type has multiple fields referencing the same parent model (e.g. primary_device and backup_device both point at Device), the button becomes a split-dropdown listing each field. The button is hidden for users without add_customobject permission. Tabs with hide_if_empty=True remain hidden until the first object is created via the native menu — subsequent additions can use the new button. The button sits in the same .btn-list as the existing bulk action buttons at full button size (no btn-sm) so heights match. --- .../netbox_custom_objects_tab/typed/tab.html | 28 +- netbox_custom_objects_tab/views/typed.py | 65 +++- tests/conftest.py | 65 ++-- tests/settings.py | 12 +- tests/test_views_typed_smoke.py | 294 +++++++++++++++--- 5 files changed, 383 insertions(+), 81 deletions(-) diff --git a/netbox_custom_objects_tab/templates/netbox_custom_objects_tab/typed/tab.html b/netbox_custom_objects_tab/templates/netbox_custom_objects_tab/typed/tab.html index 3ad9097..400d2ce 100644 --- a/netbox_custom_objects_tab/templates/netbox_custom_objects_tab/typed/tab.html +++ b/netbox_custom_objects_tab/templates/netbox_custom_objects_tab/typed/tab.html @@ -5,7 +5,6 @@ {% load i18n %} {% block content %} {% if table %} -
{# Results / Filters inner tabs #}