From e443d719d40a0cca2bb7e2a7a43214a8bcee9c5c Mon Sep 17 00:00:00 2001 From: maximumG Date: Mon, 27 Sep 2021 10:59:23 +0200 Subject: [PATCH] feat: reports within a module can now be ordered --- netbox/extras/reports.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netbox/extras/reports.py b/netbox/extras/reports.py index 64fbffb46..cc623b37c 100644 --- a/netbox/extras/reports.py +++ b/netbox/extras/reports.py @@ -59,8 +59,10 @@ def get_reports(): # defined. for importer, module_name, _ in pkgutil.iter_modules([settings.REPORTS_ROOT]): module = importer.find_module(module_name).load_module(module_name) - report_list = [cls() for _, cls in inspect.getmembers(module, is_report)] - module_list.append((module_name, report_list)) + report_order = getattr(module, "report_order", ()) + ordered_reports = [cls() for cls in report_order if is_report(cls)] + unordered_reports = [cls() for _, cls in inspect.getmembers(module, is_report) if cls not in report_order] + module_list.append((module_name, [*ordered_reports, *unordered_reports])) return module_list