diff --git a/netbox/extras/reports.py b/netbox/extras/reports.py index 90ffe0cc5..969fb3369 100644 --- a/netbox/extras/reports.py +++ b/netbox/extras/reports.py @@ -16,7 +16,7 @@ def get_report(module_name, report_name): Return a specific report from within a module. """ module = ReportModule.objects.get(file_path=f'{module_name}.py') - return module.scripts.get(report_name) + return module.reports.get(report_name) @job('default') diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 19b1ba7c3..3d9419263 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -826,13 +826,6 @@ class ReportListView(ContentTypePermissionRequiredMixin, View): ).order_by('name', '-created').distinct('name').defer('data') } - # for module, report_list in reports.items(): - # module_reports = [] - # for report in report_list.values(): - # report.result = results.get(report.full_name, None) - # module_reports.append(report) - # ret.append((module, module_reports)) - return render(request, 'extras/report_list.html', { 'model': ScriptModule, 'report_modules': report_modules, @@ -971,10 +964,6 @@ class ScriptListView(ContentTypePermissionRequiredMixin, View): ).order_by('name', '-created').distinct('name').defer('data') } - # for _scripts in scripts.values(): - # for script in _scripts.values(): - # script.result = results.get(script.full_name) - return render(request, 'extras/script_list.html', { 'model': ScriptModule, 'script_modules': script_modules, diff --git a/netbox/templates/extras/report_list.html b/netbox/templates/extras/report_list.html index 72eb3b43d..e919d93d2 100644 --- a/netbox/templates/extras/report_list.html +++ b/netbox/templates/extras/report_list.html @@ -44,7 +44,8 @@ Name Status Description - Last Run + Last Run + Last Status @@ -58,29 +59,35 @@ {% include 'extras/inc/job_label.html' with result=report.result %} {{ report.description|markdown|placeholder }} - - {% if report.result %} - {{ report.result.created|annotated_date }} + {% with last_result=job_results|get_key:report.full_name %} + {% if last_result %} + + {{ last_result.created|annotated_date }} + + + {% badge last_result.get_status_display last_result.get_status_color %} + {% else %} - Never + Never + {{ ''|placeholder }} {% endif %} - - - {% if perms.extras.run_report %} -
-
- {% csrf_token %} - -
-
- {% endif %} - + + {% if perms.extras.run_report %} +
+
+ {% csrf_token %} + +
+
+ {% endif %} + + {% endwith %} {% for method, stats in report.result.data.items %} diff --git a/netbox/templates/extras/script_list.html b/netbox/templates/extras/script_list.html index 171a02e8b..9d5771cff 100644 --- a/netbox/templates/extras/script_list.html +++ b/netbox/templates/extras/script_list.html @@ -43,7 +43,8 @@ Name Status Description - Last Run + Last Run + Status @@ -58,13 +59,19 @@ {{ script_class.Meta.description|markdown|placeholder }} - {% if script_class.result %} - - {{ script_class.result.created|annotated_date }} - - {% else %} - Never - {% endif %} + {% with last_result=job_results|get_key:script_class.full_name %} + {% if last_result %} + + {{ last_result.created|annotated_date }} + + + {% badge last_result.get_status_display last_result.get_status_color %} + + {% else %} + Never + {{ ''|placeholder }} + {% endif %} + {% endwith %} {% endfor %}