mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
12510 fixes
This commit is contained in:
parent
e61b960cd7
commit
53b3875e82
@ -8,6 +8,7 @@ def migrate_report_jobs(apps, schema_editor):
|
|||||||
Job = apps.get_model('core', 'Job')
|
Job = apps.get_model('core', 'Job')
|
||||||
|
|
||||||
# Delete the new ContentType effected by the introduction of core.ConfigRevision
|
# Delete the new ContentType effected by the introduction of core.ConfigRevision
|
||||||
|
if ContentType.objects.filter(app_label='extras', model='reportmodule'):
|
||||||
report_content_type = ContentType.objects.get(app_label='extras', model='reportmodule')
|
report_content_type = ContentType.objects.get(app_label='extras', model='reportmodule')
|
||||||
script_content_type = ContentType.objects.get(app_label='extras', model='scriptmodule')
|
script_content_type = ContentType.objects.get(app_label='extras', model='scriptmodule')
|
||||||
jobs = Job.objects.filter(object_type_id=report_content_type.id).update(object_type_id=script_content_type.id)
|
jobs = Job.objects.filter(object_type_id=report_content_type.id).update(object_type_id=script_content_type.id)
|
||||||
|
@ -730,37 +730,6 @@ class ConfigTemplateTest(APIViewTestCases.APIViewTestCase):
|
|||||||
ConfigTemplate.objects.bulk_create(config_templates)
|
ConfigTemplate.objects.bulk_create(config_templates)
|
||||||
|
|
||||||
|
|
||||||
class ReportTest(APITestCase):
|
|
||||||
|
|
||||||
class TestReport(Report):
|
|
||||||
|
|
||||||
def test_foo(self):
|
|
||||||
self.log_success(None, "Report completed")
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(cls):
|
|
||||||
ReportModule.objects.create(
|
|
||||||
file_root=ManagedFileRootPathChoices.REPORTS,
|
|
||||||
file_path='/var/tmp/report.py'
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_test_report(self, *args):
|
|
||||||
return ReportModule.objects.first(), self.TestReport()
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super().setUp()
|
|
||||||
|
|
||||||
# Monkey-patch the API viewset's _get_report() method to return our test Report above
|
|
||||||
from extras.api.views import ReportViewSet
|
|
||||||
ReportViewSet._get_report = self.get_test_report
|
|
||||||
|
|
||||||
def test_get_report(self):
|
|
||||||
url = reverse('extras-api:report-detail', kwargs={'pk': None})
|
|
||||||
response = self.client.get(url, **self.header)
|
|
||||||
|
|
||||||
self.assertEqual(response.data['name'], self.TestReport.__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class ScriptTest(APITestCase):
|
class ScriptTest(APITestCase):
|
||||||
|
|
||||||
class TestScript(Script):
|
class TestScript(Script):
|
||||||
|
@ -1165,15 +1165,10 @@ class ScriptResultView(ContentTypePermissionRequiredMixin, View):
|
|||||||
|
|
||||||
legacy_script = False
|
legacy_script = False
|
||||||
legacy_report = False
|
legacy_report = False
|
||||||
if job.data:
|
if job.data and ('logs' not in job.data):
|
||||||
if 'logs' in job.data:
|
if 'log' in job.data:
|
||||||
legacy_script = False
|
|
||||||
legacy_report = False
|
|
||||||
elif 'log' in job.data:
|
|
||||||
legacy_script = True
|
legacy_script = True
|
||||||
legacy_report = False
|
|
||||||
else:
|
else:
|
||||||
legacy_script = False
|
|
||||||
legacy_report = True
|
legacy_report = True
|
||||||
|
|
||||||
# If this is an HTMX request, return only the result HTML
|
# If this is an HTMX request, return only the result HTML
|
||||||
|
@ -32,8 +32,11 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<h2 class="card-header">{% trans "Script Results" %}</h2>
|
||||||
|
|
||||||
|
{% for method, data in job.data.logs.items %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5 class="card-header">{% trans "Script Results" %}</h5>
|
<h5 class="card-header"><a name="{{ method }}"></a>{{ method }}</h5>
|
||||||
<table class="table table-hover script">
|
<table class="table table-hover script">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -44,13 +47,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for method, data in job.data.logs.items %}
|
|
||||||
{% if method != 'total' %}
|
|
||||||
<tr>
|
|
||||||
<th colspan="4" style="font-family: monospace">
|
|
||||||
<a name="{{ method }}"></a>{{ method }}
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
{% for time, level, obj, url, message in data.log %}
|
{% for time, level, obj, url, message in data.log %}
|
||||||
<tr class="{% if level == 'failure' %}danger{% elif level %}{{ level }}{% endif %}">
|
<tr class="{% if level == 'failure' %}danger{% elif level %}{{ level }}{% endif %}">
|
||||||
<td>{{ time }}</td>
|
<td>{{ time }}</td>
|
||||||
@ -69,11 +65,10 @@
|
|||||||
<td class="rendered-markdown">{{ message|markdown }}</td>
|
<td class="rendered-markdown">{{ message|markdown }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{% endfor %}
|
||||||
{% elif job.started %}
|
{% elif job.started %}
|
||||||
{% include 'extras/inc/result_pending.html' %}
|
{% include 'extras/inc/result_pending.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user