14728 review fixes

This commit is contained in:
Arthur 2024-01-18 10:19:44 -08:00
parent 4b1072afcb
commit 98e04071c8
7 changed files with 26 additions and 46 deletions

View File

@ -1,3 +1,4 @@
from .config import * from .config import *
from .data import * from .data import *
from .jobs import * from .jobs import *
from .plugins import *

View File

@ -35,4 +35,6 @@ urlpatterns = (
# Configuration # Configuration
path('config/', views.ConfigView.as_view(), name='config'), path('config/', views.ConfigView.as_view(), name='config'),
# Plugins
path('plugins/', views.PluginListView.as_view(), name='plugin_list'),
) )

View File

@ -1,4 +1,7 @@
from django.apps import apps
from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.cache import cache from django.core.cache import cache
from django.http import HttpResponseForbidden from django.http import HttpResponseForbidden
from django.shortcuts import get_object_or_404, redirect, render 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}") messages.success(request, f"Restored configuration revision #{pk}")
return redirect(candidate_config.get_absolute_url()) 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,
})

View File

@ -5,7 +5,7 @@ from django.conf import settings
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from extras.models import * from extras.models import *
from netbox.tables import BaseTable, NetBoxTable, columns from netbox.tables import NetBoxTable, columns
from .template_code import * from .template_code import *
__all__ = ( __all__ = (
@ -20,7 +20,6 @@ __all__ = (
'ImageAttachmentTable', 'ImageAttachmentTable',
'JournalEntryTable', 'JournalEntryTable',
'ObjectChangeTable', 'ObjectChangeTable',
'PluginTable',
'SavedFilterTable', 'SavedFilterTable',
'TaggedItemTable', 'TaggedItemTable',
'TagTable', 'TagTable',
@ -508,24 +507,3 @@ class JournalEntryTable(NetBoxTable):
default_columns = ( default_columns = (
'pk', 'created', 'created_by', 'assigned_object_type', 'assigned_object', 'kind', 'comments' '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',
}

View File

@ -136,8 +136,4 @@ urlpatterns = [
# Markdown # Markdown
path('render/markdown/', views.RenderMarkdownView.as_view(), name="render_markdown"), path('render/markdown/', views.RenderMarkdownView.as_view(), name="render_markdown"),
# Plugins
path('plugins/', views.PluginListView.as_view(), name='plugin_list'),
] ]

View File

@ -1375,21 +1375,3 @@ class RenderMarkdownView(View):
rendered = render_markdown(form.cleaned_data['text']) rendered = render_markdown(form.cleaned_data['text'])
return HttpResponse(rendered) 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,
})

View File

@ -454,7 +454,7 @@ ADMIN_MENU = Menu(
label=_('Plugins'), label=_('Plugins'),
items=( items=(
MenuItem( MenuItem(
link='extras:plugin_list', link='core:plugin_list',
link_text=_('Plugins'), link_text=_('Plugins'),
staff_only=True staff_only=True
), ),