diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-09-13 14:50:10 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-09-13 14:50:10 +0100 |
commit | 77fdd7cd39bd6166932eb5286b251de79de0a57d (patch) | |
tree | f63e86efd270a5872b0a81e3495e3e63bbaa8c8f /app/controllers/public_body_controller.rb | |
parent | 0bf0be30cfbb866727a98ae22444aa0a724288b1 (diff) | |
parent | a622b31a33658696525ad675cdeb1e433f2a7c8b (diff) |
Merge branch 'develop' of git.mysociety.org:/data/git/public/alaveteli into develop
Diffstat (limited to 'app/controllers/public_body_controller.rb')
-rw-r--r-- | app/controllers/public_body_controller.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 95d936e54..b8ea82a66 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -7,7 +7,7 @@ # # $Id: public_body_controller.rb,v 1.8 2009-09-14 13:27:00 francis Exp $ -require 'csv' +require 'fastercsv' class PublicBodyController < ApplicationController # XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL @@ -148,10 +148,10 @@ class PublicBodyController < ApplicationController end def list_all_csv - public_bodies = PublicBody.find(:all, :order => 'url_name') - report = StringIO.new - CSV::Writer.generate(report, ',') do |title| - title << [ + public_bodies = PublicBody.find(:all, :order => 'url_name', + :include => [:translations, :tags]) + report = FasterCSV.generate() do |csv| + csv << [ 'Name', 'Short name', # deliberately not including 'Request email' @@ -164,7 +164,7 @@ class PublicBodyController < ApplicationController 'Version', ] public_bodies.each do |public_body| - title << [ + csv << [ public_body.name, public_body.short_name, # DO NOT include request_email (we don't want to make it @@ -179,8 +179,7 @@ class PublicBodyController < ApplicationController ] end end - report.rewind - send_data(report.read, :type=> 'text/csv; charset=utf-8; header=present', + send_data(report, :type=> 'text/csv; charset=utf-8; header=present', :filename => 'all-authorities.csv', :disposition =>'attachment', :encoding => 'utf8') end |