Use table for ordering

This commit is contained in:
Jeremy Stretch 2024-07-17 10:28:35 -04:00
parent 62287662d5
commit b31eb0371d
2 changed files with 5 additions and 12 deletions

View File

@ -70,3 +70,6 @@ class CatalogPluginTable(BaseTable):
default_columns = (
'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')

View File

@ -582,7 +582,7 @@ class WorkerView(BaseRQView):
#
# Plugins
# System
#
class SystemView(UserPassesTestMixin, View):
@ -652,20 +652,10 @@ class PluginListView(UserPassesTestMixin, View):
def get(self, request):
q = request.GET.get('q', None)
plugins = get_plugins()
plugins = plugins.values()
plugins = get_plugins().values()
if q:
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.configure(request)