Refactors the CSV piece to be nicer than it previously was.

This commit is contained in:
Christopher Neugebauer 2016-08-15 10:17:27 +10:00
parent 9e498544c2
commit 2a6c192449

View file

@ -147,6 +147,10 @@ def review_all_proposals_csv(request):
''' Returns a CSV representation of all of the proposals this user has
permisison to review. '''
response = HttpResponse("text/csv")
response['Content-Disposition'] = 'attachment; filename="proposals.csv"'
writer = csv.writer(response, quoting=csv.QUOTE_NONNUMERIC)
queryset = ProposalBase.objects.filter()
# The fields from each proposal object to report in the csv
@ -156,9 +160,6 @@ def review_all_proposals_csv(request):
"score", "total_votes", "minus_two", "minus_one", "plus_one", "plus_two",
]
output = StringIO.StringIO()
writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
# Fields are the heading
writer.writerow(fields)
@ -180,7 +181,7 @@ def review_all_proposals_csv(request):
writer.writerow(csv_line)
return HttpResponse(output.getvalue(), "text/csv")
return response
@login_required