diff --git a/netbox/core/tables/data.py b/netbox/core/tables/data.py index 5c6ccebcf..50b7821fe 100644 --- a/netbox/core/tables/data.py +++ b/netbox/core/tables/data.py @@ -4,6 +4,7 @@ import django_tables2 as tables from core.models import * from netbox.tables import NetBoxTable, columns from .columns import BackendTypeColumn +from .template_code import DATA_SOURCE_SYNC_BUTTONS __all__ = ( 'DataFileTable', @@ -37,6 +38,9 @@ class DataSourceTable(NetBoxTable): tags = columns.TagColumn( url_name='core:datasource_list', ) + actions = columns.ActionsColumn( + extra_buttons=DATA_SOURCE_SYNC_BUTTONS, + ) class Meta(NetBoxTable.Meta): model = DataSource diff --git a/netbox/core/tables/template_code.py b/netbox/core/tables/template_code.py index 9fc652c4c..e9c2aabd1 100644 --- a/netbox/core/tables/template_code.py +++ b/netbox/core/tables/template_code.py @@ -26,3 +26,21 @@ PLUGIN_IS_INSTALLED = """ {% endif %} """ + +DATA_SOURCE_SYNC_BUTTONS = """ +{% load helpers %} +{% load i18n %} + {% if perms.core.sync_datasource %} + {% if record.ready_for_sync %} + + {% else %} + + + + {% endif %} + {% endif %} +""" diff --git a/netbox/core/views.py b/netbox/core/views.py index b18937308..947e03681 100644 --- a/netbox/core/views.py +++ b/netbox/core/views.py @@ -85,6 +85,8 @@ class DataSourceSyncView(BaseObjectView): request, _("Queued job #{id} to sync {datasource}").format(id=job.pk, datasource=datasource) ) + if return_url := request.POST.get('return_url'): + return redirect(return_url) return redirect(datasource.get_absolute_url())