def itsystem_dependency_report_all(self, request):
"""Returns a CSV containing all recorded dependencies.
"""
fields = [
'IT System', 'System status', 'Dependency', 'Dependency status',
'Criticality', 'Description']
# Write data for ITSystemHardware objects to the CSV.
stream = StringIO()
wr = unicodecsv.writer(stream, encoding='utf-8')
wr.writerow(fields) # CSV header row.
for i in ITSystemDependency.objects.all():
wr.writerow([
i.itsystem.name, i.itsystem.get_status_display(),
i.dependency.name, i.dependency.get_status_display(),
i.get_criticality_display(), i.description])
response = HttpResponse(stream.getvalue(), content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=itsystemdependency_all.csv'
return response
评论列表
文章目录