mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 20:22:53 -06:00
#13666: Add is_valid property to Report class
This commit is contained in:
parent
e67624f042
commit
f9ceaad284
@ -135,6 +135,13 @@ class Report(object):
|
|||||||
def source(self):
|
def source(self):
|
||||||
return inspect.getsource(self.__class__)
|
return inspect.getsource(self.__class__)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_valid(self):
|
||||||
|
"""
|
||||||
|
Indicates whether the report can be run.
|
||||||
|
"""
|
||||||
|
return bool(self.test_methods)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Logging methods
|
# Logging methods
|
||||||
#
|
#
|
||||||
|
@ -8,15 +8,17 @@
|
|||||||
{% if perms.extras.run_report %}
|
{% if perms.extras.run_report %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
{% if not report.is_valid %}
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
<i class="mdi mdi-alert"></i>
|
||||||
|
{% trans "This report is invalid and cannot be run." %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post" class="form-object-edit">
|
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post" class="form-object-edit">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% render_form form %}
|
{% render_form form %}
|
||||||
<div class="float-end">
|
<div class="float-end">
|
||||||
<button type="submit" name="_run" class="btn btn-primary"
|
<button type="submit" name="_run" class="btn btn-primary"{% if not report.is_valid %} disabled{% endif %}>
|
||||||
{% if not report.test_methods|length %}
|
|
||||||
disabled
|
|
||||||
{% endif %}
|
|
||||||
>
|
|
||||||
{% if report.result %}
|
{% if report.result %}
|
||||||
<i class="mdi mdi-replay"></i> {% trans "Run Again" %}
|
<i class="mdi mdi-replay"></i> {% trans "Run Again" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -68,16 +68,18 @@
|
|||||||
</td>
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td class="text-muted">{% trans "Never" %}</td>
|
<td class="text-muted">{% trans "Never" %}</td>
|
||||||
{% if report.test_methods|length %}
|
<td>
|
||||||
<td>{{ ''|placeholder }}</td>
|
{% if report.is_valid %}
|
||||||
{% else %}
|
{{ ''|placeholder }}
|
||||||
<td>
|
{% else %}
|
||||||
Invalid (no test methods found)
|
<span class="badge bg-danger" title="{% trans "Report has no test methods" %}">
|
||||||
</td>
|
{% trans "Invalid" %}
|
||||||
{% endif %}
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
{% if perms.extras.run_report and report.test_methods|length %}
|
{% if perms.extras.run_report and report.is_valid %}
|
||||||
<div class="float-end noprint">
|
<div class="float-end noprint">
|
||||||
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
Loading…
Reference in New Issue
Block a user