1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Moved ReportResult creation into Report.run()

This commit is contained in:
Jeremy Stretch
2017-09-28 12:50:32 -04:00
parent 2fbb39bf6f
commit 571b817f04
2 changed files with 18 additions and 18 deletions

View File

@@ -153,14 +153,9 @@ class ReportViewSet(ViewSet):
if not request.user.has_perm('extras.add_reportresult'):
raise PermissionDenied("This user does not have permission to run reports.")
# Retrieve and run the Report.
# Retrieve and run the Report. This will create a new ReportResult.
report = self._retrieve_report(pk)
result = report.run()
# Delete the old ReportResult (if any) and save the new one.
ReportResult.objects.filter(report=pk).delete()
report.result = ReportResult(report=pk, failed=report.failed, data=result)
report.result.save()
report.run()
serializer = serializers.ReportDetailSerializer(report)