From 98e04071c8987ce4a90ecc7591b169e75252796c Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 18 Jan 2024 10:19:44 -0800 Subject: [PATCH] 14728 review fixes --- netbox/core/tables/__init__.py | 1 + netbox/core/urls.py | 2 ++ netbox/core/views.py | 21 +++++++++++++++++++++ netbox/extras/tables/tables.py | 24 +----------------------- netbox/extras/urls.py | 4 ---- netbox/extras/views.py | 18 ------------------ netbox/netbox/navigation/menu.py | 2 +- 7 files changed, 26 insertions(+), 46 deletions(-) diff --git a/netbox/core/tables/__init__.py b/netbox/core/tables/__init__.py index 69f9d8a48..29dc7d85e 100644 --- a/netbox/core/tables/__init__.py +++ b/netbox/core/tables/__init__.py @@ -1,3 +1,4 @@ from .config import * from .data import * from .jobs import * +from .plugins import * diff --git a/netbox/core/urls.py b/netbox/core/urls.py index 77c0d3194..3bb5cd24c 100644 --- a/netbox/core/urls.py +++ b/netbox/core/urls.py @@ -35,4 +35,6 @@ urlpatterns = ( # Configuration path('config/', views.ConfigView.as_view(), name='config'), + # Plugins + path('plugins/', views.PluginListView.as_view(), name='plugin_list'), ) diff --git a/netbox/core/views.py b/netbox/core/views.py index 537c33d9d..0617b8c34 100644 --- a/netbox/core/views.py +++ b/netbox/core/views.py @@ -1,4 +1,7 @@ +from django.apps import apps +from django.conf import settings from django.contrib import messages +from django.contrib.auth.mixins import LoginRequiredMixin from django.core.cache import cache from django.http import HttpResponseForbidden from django.shortcuts import get_object_or_404, redirect, render @@ -232,3 +235,21 @@ class ConfigRevisionRestoreView(ContentTypePermissionRequiredMixin, View): messages.success(request, f"Restored configuration revision #{pk}") return redirect(candidate_config.get_absolute_url()) + + +# +# Plugins +# + +class PluginListView(LoginRequiredMixin, View): + + def get(self, request): + plugins = [apps.get_app_config(plugin) for plugin in settings.PLUGINS] + table = tables.PluginTable(plugins) + # table.configure(request) + + return render(request, 'extras/plugin_list.html', { + 'plugins': plugins, + 'active_tab': 'api-tokens', + 'table': table, + }) diff --git a/netbox/extras/tables/tables.py b/netbox/extras/tables/tables.py index ac13b5dd2..8482c5e24 100644 --- a/netbox/extras/tables/tables.py +++ b/netbox/extras/tables/tables.py @@ -5,7 +5,7 @@ from django.conf import settings from django.utils.translation import gettext_lazy as _ from extras.models import * -from netbox.tables import BaseTable, NetBoxTable, columns +from netbox.tables import NetBoxTable, columns from .template_code import * __all__ = ( @@ -20,7 +20,6 @@ __all__ = ( 'ImageAttachmentTable', 'JournalEntryTable', 'ObjectChangeTable', - 'PluginTable', 'SavedFilterTable', 'TaggedItemTable', 'TagTable', @@ -508,24 +507,3 @@ class JournalEntryTable(NetBoxTable): default_columns = ( 'pk', 'created', 'created_by', 'assigned_object_type', 'assigned_object', 'kind', 'comments' ) - - -class PluginTable(BaseTable): - verbose_name = tables.Column() - name = tables.Column() - author = tables.Column() - author_email = tables.Column() - description = tables.Column() - version = tables.Column() - - class Meta: - empty_text = _('No plugins found') - fields = ( - 'verbose_name', 'name', 'author', 'author_email', 'description', 'version', - ) - default_columns = ( - 'verbose_name', 'name', 'author', 'author_email', 'description', 'version', - ) - attrs = { - 'class': 'table table-hover object-list', - } diff --git a/netbox/extras/urls.py b/netbox/extras/urls.py index c760128d5..0a1786f1f 100644 --- a/netbox/extras/urls.py +++ b/netbox/extras/urls.py @@ -136,8 +136,4 @@ urlpatterns = [ # Markdown path('render/markdown/', views.RenderMarkdownView.as_view(), name="render_markdown"), - - # Plugins - path('plugins/', views.PluginListView.as_view(), name='plugin_list'), - ] diff --git a/netbox/extras/views.py b/netbox/extras/views.py index de8ba63ed..5a1fbf19e 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -1375,21 +1375,3 @@ class RenderMarkdownView(View): rendered = render_markdown(form.cleaned_data['text']) return HttpResponse(rendered) - - -# -# Plugins -# - -class PluginListView(LoginRequiredMixin, View): - - def get(self, request): - plugins = [apps.get_app_config(plugin) for plugin in settings.PLUGINS] - table = tables.PluginTable(plugins) - # table.configure(request) - - return render(request, 'extras/plugin_list.html', { - 'plugins': plugins, - 'active_tab': 'api-tokens', - 'table': table, - }) diff --git a/netbox/netbox/navigation/menu.py b/netbox/netbox/navigation/menu.py index eac0c36d4..e63947424 100644 --- a/netbox/netbox/navigation/menu.py +++ b/netbox/netbox/navigation/menu.py @@ -454,7 +454,7 @@ ADMIN_MENU = Menu( label=_('Plugins'), items=( MenuItem( - link='extras:plugin_list', + link='core:plugin_list', link_text=_('Plugins'), staff_only=True ),