1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

feat: reports within a module can now be ordered

This commit is contained in:
maximumG
2021-09-27 10:59:23 +02:00
parent 7ec6b4ebb7
commit e443d719d4

View File

@ -59,8 +59,10 @@ def get_reports():
# defined. # defined.
for importer, module_name, _ in pkgutil.iter_modules([settings.REPORTS_ROOT]): for importer, module_name, _ in pkgutil.iter_modules([settings.REPORTS_ROOT]):
module = importer.find_module(module_name).load_module(module_name) module = importer.find_module(module_name).load_module(module_name)
report_list = [cls() for _, cls in inspect.getmembers(module, is_report)] report_order = getattr(module, "report_order", ())
module_list.append((module_name, report_list)) 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 return module_list