From f9ceaad2845ecde99a6faa4f63fdf802d11b85cd Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 26 Sep 2023 10:53:38 -0400 Subject: [PATCH] #13666: Add is_valid property to Report class --- netbox/extras/reports.py | 7 +++++++ netbox/templates/extras/report.html | 12 +++++++----- netbox/templates/extras/report_list.html | 18 ++++++++++-------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/netbox/extras/reports.py b/netbox/extras/reports.py index 284f69d77..9b12065ca 100644 --- a/netbox/extras/reports.py +++ b/netbox/extras/reports.py @@ -135,6 +135,13 @@ class Report(object): def source(self): return inspect.getsource(self.__class__) + @property + def is_valid(self): + """ + Indicates whether the report can be run. + """ + return bool(self.test_methods) + # # Logging methods # diff --git a/netbox/templates/extras/report.html b/netbox/templates/extras/report.html index 717c24eab..806279d20 100644 --- a/netbox/templates/extras/report.html +++ b/netbox/templates/extras/report.html @@ -8,15 +8,17 @@ {% if perms.extras.run_report %}
+ {% if not report.is_valid %} +
+ + {% trans "This report is invalid and cannot be run." %} +
+ {% endif %}
{% csrf_token %} {% render_form form %}
-