mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Simplify conditional logic; tweak timestamp format
This commit is contained in:
parent
5d71a4e3e2
commit
e5bf33fc47
@ -1476,18 +1476,17 @@ class ScriptResultView(TableMixin, generic.ObjectView):
|
||||
table = None
|
||||
job = get_object_or_404(Job.objects.all(), pk=kwargs.get('job_pk'))
|
||||
|
||||
if job.completed:
|
||||
table = self.get_table(job, request, bulk_actions=False)
|
||||
# If a direct export output has been requested, return the job data content as a
|
||||
# downloadable file.
|
||||
if job.completed and request.GET.get('export') == 'output':
|
||||
content = (job.data.get("output") or "").encode()
|
||||
response = HttpResponse(content, content_type='text')
|
||||
filename = f"{job.object.name or 'script-output'}_{job.completed.strftime('%Y-%m-%d_%H%M%S')}.txt"
|
||||
response['Content-Disposition'] = f'attachment; filename="{filename}"'
|
||||
return response
|
||||
|
||||
if job.completed:
|
||||
# If a direct export output has been requested, return the job data content as a
|
||||
# downloadable file.
|
||||
if request.GET.get('export') == 'output':
|
||||
content = (job.data.get("output") or "").encode()
|
||||
response = HttpResponse(content, content_type='text')
|
||||
filename = f"{job.object.name or 'script-output'}_{job.completed.strftime('%Y-%m-%d-%H-%M-%S')}.txt"
|
||||
response['Content-Disposition'] = f'attachment; filename="{filename}"'
|
||||
return response
|
||||
elif job.completed:
|
||||
table = self.get_table(job, request, bulk_actions=False)
|
||||
|
||||
log_threshold = request.GET.get('log_threshold', LogLevelChoices.LOG_INFO)
|
||||
if log_threshold not in LOG_LEVEL_RANK:
|
||||
|
Loading…
Reference in New Issue
Block a user