From 2a6c19244936e23af23eb71153ec53b30ab53145 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 10:17:27 +1000 Subject: [PATCH] Refactors the CSV piece to be nicer than it previously was. --- symposion/reviews/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index 6531b20e..b4dd8d99 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -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