mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 08:38:16 -06:00
Use table for ordering
This commit is contained in:
parent
62287662d5
commit
b31eb0371d
@ -70,3 +70,6 @@ class CatalogPluginTable(BaseTable):
|
|||||||
default_columns = (
|
default_columns = (
|
||||||
'name', 'author', 'is_local', 'is_installed', 'is_certified', 'created', 'updated',
|
'name', 'author', 'is_local', 'is_installed', 'is_certified', 'created', 'updated',
|
||||||
)
|
)
|
||||||
|
# List installed plugins first, then certified plugins, then
|
||||||
|
# everything else (with each tranche ordered alphabetically)
|
||||||
|
order_by = ('-is_installed', '-is_certified', 'name')
|
||||||
|
@ -582,7 +582,7 @@ class WorkerView(BaseRQView):
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Plugins
|
# System
|
||||||
#
|
#
|
||||||
|
|
||||||
class SystemView(UserPassesTestMixin, View):
|
class SystemView(UserPassesTestMixin, View):
|
||||||
@ -652,20 +652,10 @@ class PluginListView(UserPassesTestMixin, View):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
q = request.GET.get('q', None)
|
q = request.GET.get('q', None)
|
||||||
|
|
||||||
plugins = get_plugins()
|
plugins = get_plugins().values()
|
||||||
plugins = plugins.values()
|
|
||||||
if q:
|
if q:
|
||||||
plugins = [obj for obj in plugins if q.casefold() in obj.name.casefold()]
|
plugins = [obj for obj in plugins if q.casefold() in obj.name.casefold()]
|
||||||
|
|
||||||
# Sort order should be:
|
|
||||||
# Installed plugins
|
|
||||||
# Certified catalog plugins
|
|
||||||
# Remaining catalog plugins
|
|
||||||
# With alphabetical sort within each traunch.
|
|
||||||
plugins = sorted(plugins, key=lambda x: x.name, reverse=False)
|
|
||||||
plugins = sorted(plugins, key=lambda x: x.is_certified, reverse=True)
|
|
||||||
plugins = sorted(plugins, key=lambda x: x.is_installed, reverse=True)
|
|
||||||
|
|
||||||
table = CatalogPluginTable(plugins, user=request.user)
|
table = CatalogPluginTable(plugins, user=request.user)
|
||||||
table.configure(request)
|
table.configure(request)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user