mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Fixes #12463: Fix the association of completed jobs with reports & scripts in the REST API
This commit is contained in:
parent
42c80f69e6
commit
a29a07ed26
@ -34,6 +34,7 @@
|
|||||||
* [#12415](https://github.com/netbox-community/netbox/issues/12415) - Fix `ImportError` exception when running RQ worker
|
* [#12415](https://github.com/netbox-community/netbox/issues/12415) - Fix `ImportError` exception when running RQ worker
|
||||||
* [#12433](https://github.com/netbox-community/netbox/issues/12433) - Correct the application of URL query parameters for object list dashboard widgets
|
* [#12433](https://github.com/netbox-community/netbox/issues/12433) - Correct the application of URL query parameters for object list dashboard widgets
|
||||||
* [#12436](https://github.com/netbox-community/netbox/issues/12436) - Remove extraneous "add" button from contact assignments list
|
* [#12436](https://github.com/netbox-community/netbox/issues/12436) - Remove extraneous "add" button from contact assignments list
|
||||||
|
* [#12463](https://github.com/netbox-community/netbox/issues/12463) - Fix the association of completed jobs with reports & scripts in the REST API
|
||||||
* [#12464](https://github.com/netbox-community/netbox/issues/12464) - Apply credentials for git data source only when connecting via HTTP/S
|
* [#12464](https://github.com/netbox-community/netbox/issues/12464) - Apply credentials for git data source only when connecting via HTTP/S
|
||||||
* [#12476](https://github.com/netbox-community/netbox/issues/12476) - Fix `TypeError` exception when running the `runscript` management command
|
* [#12476](https://github.com/netbox-community/netbox/issues/12476) - Fix `TypeError` exception when running the `runscript` management command
|
||||||
* [#12483](https://github.com/netbox-community/netbox/issues/12483) - Fix git remote data syncing when with HTTP proxies defined
|
* [#12483](https://github.com/netbox-community/netbox/issues/12483) - Fix git remote data syncing when with HTTP proxies defined
|
||||||
|
@ -187,11 +187,10 @@ class ReportViewSet(ViewSet):
|
|||||||
"""
|
"""
|
||||||
Compile all reports and their related results (if any). Result data is deferred in the list view.
|
Compile all reports and their related results (if any). Result data is deferred in the list view.
|
||||||
"""
|
"""
|
||||||
report_content_type = ContentType.objects.get(app_label='extras', model='report')
|
|
||||||
results = {
|
results = {
|
||||||
r.name: r
|
job.name: job
|
||||||
for r in Job.objects.filter(
|
for job in Job.objects.filter(
|
||||||
object_type=report_content_type,
|
object_type=ContentType.objects.get(app_label='extras', model='reportmodule'),
|
||||||
status__in=JobStatusChoices.TERMINAL_STATE_CHOICES
|
status__in=JobStatusChoices.TERMINAL_STATE_CHOICES
|
||||||
).order_by('name', '-created').distinct('name').defer('data')
|
).order_by('name', '-created').distinct('name').defer('data')
|
||||||
}
|
}
|
||||||
@ -202,7 +201,7 @@ class ReportViewSet(ViewSet):
|
|||||||
|
|
||||||
# Attach Job objects to each report (if any)
|
# Attach Job objects to each report (if any)
|
||||||
for report in report_list:
|
for report in report_list:
|
||||||
report.result = results.get(report.full_name, None)
|
report.result = results.get(report.name, None)
|
||||||
|
|
||||||
serializer = serializers.ReportSerializer(report_list, many=True, context={
|
serializer = serializers.ReportSerializer(report_list, many=True, context={
|
||||||
'request': request,
|
'request': request,
|
||||||
@ -290,12 +289,10 @@ class ScriptViewSet(ViewSet):
|
|||||||
return module, script
|
return module, script
|
||||||
|
|
||||||
def list(self, request):
|
def list(self, request):
|
||||||
|
|
||||||
script_content_type = ContentType.objects.get(app_label='extras', model='script')
|
|
||||||
results = {
|
results = {
|
||||||
r.name: r
|
job.name: job
|
||||||
for r in Job.objects.filter(
|
for job in Job.objects.filter(
|
||||||
object_type=script_content_type,
|
object_type=ContentType.objects.get(app_label='extras', model='scriptmodule'),
|
||||||
status__in=JobStatusChoices.TERMINAL_STATE_CHOICES
|
status__in=JobStatusChoices.TERMINAL_STATE_CHOICES
|
||||||
).order_by('name', '-created').distinct('name').defer('data')
|
).order_by('name', '-created').distinct('name').defer('data')
|
||||||
}
|
}
|
||||||
@ -306,7 +303,7 @@ class ScriptViewSet(ViewSet):
|
|||||||
|
|
||||||
# Attach Job objects to each script (if any)
|
# Attach Job objects to each script (if any)
|
||||||
for script in script_list:
|
for script in script_list:
|
||||||
script.result = results.get(script.full_name, None)
|
script.result = results.get(script.name, None)
|
||||||
|
|
||||||
serializer = serializers.ScriptSerializer(script_list, many=True, context={'request': request})
|
serializer = serializers.ScriptSerializer(script_list, many=True, context={'request': request})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user