Merge pull request #2471 from rahul2240/export

Fix broken export
This commit is contained in:
Stella Rouzi 2019-04-29 21:35:55 +03:00 committed by GitHub
commit 9bdd889e32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 16 deletions

View file

@ -134,7 +134,7 @@ gem 'country_select'
# as PDF generator # as PDF generator
gem 'prawn-qrcode' gem 'prawn-qrcode'
gem 'prawn_rails' gem 'prawn-rails'
gem 'rqrcode' gem 'rqrcode'
# to render XLS spreadsheets # to render XLS spreadsheets

View file

@ -364,9 +364,12 @@ GEM
prawn-qrcode (0.3.1) prawn-qrcode (0.3.1)
prawn (>= 1) prawn (>= 1)
rqrcode (>= 0.4.1) rqrcode (>= 0.4.1)
prawn_rails (0.0.11) prawn-rails (1.2.0)
prawn (>= 0.11.1) prawn
railties (>= 3.0.0) prawn-table
rails (>= 3.1.0)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
pry (0.10.4) pry (0.10.4)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
@ -669,7 +672,7 @@ DEPENDENCIES
pg pg
piwik_analytics (~> 1.0.1) piwik_analytics (~> 1.0.1)
prawn-qrcode prawn-qrcode
prawn_rails prawn-rails
puma (~> 3.0) puma (~> 3.0)
rails (~> 5.0.7) rails (~> 5.0.7)
rails-assets-bootstrap-markdown! rails-assets-bootstrap-markdown!

View file

@ -14,12 +14,12 @@ module Admin
format.json { render json: Booth.where(state: :confirmed, program: @program).to_json } format.json { render json: Booth.where(state: :confirmed, program: @program).to_json }
format.xlsx do format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\"" response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'booths' render 'booths', layout: false
end end
format.pdf { render 'booths' } format.pdf { render 'booths', layout: false }
format.csv do format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\"" response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'booths' render 'booths', layout: false
end end
end end
end end

View file

@ -28,12 +28,12 @@ module Admin
format.json { render json: Event.where(state: :confirmed, program: @program).to_json } format.json { render json: Event.where(state: :confirmed, program: @program).to_json }
format.xlsx do format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\"" response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'events' render 'events', layout: false
end end
format.pdf { render 'events' } format.pdf { render 'events', layout: false }
format.csv do format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\"" response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'events' render 'events', layout: false
end end
end end
end end

View file

@ -15,12 +15,22 @@ module Admin
@registration_distribution = @conference.registration_distribution @registration_distribution = @conference.registration_distribution
@affiliation_distribution = @conference.affiliation_distribution @affiliation_distribution = @conference.affiliation_distribution
@code_of_conduct = @conference.code_of_conduct.present? @code_of_conduct = @conference.code_of_conduct.present?
@file_name = "registrations_for_#{@conference.short_title}"
respond_to do |format| respond_to do |format|
format.html format.html
format.json do format.json do
render json: RegistrationDatatable.new(view_context, conference: @conference) render json: RegistrationDatatable.new(view_context, conference: @conference)
end end
format.pdf { render 'index', layout: false }
format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'index', layout: false
end
format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'index', layout: false
end
end end
end end

View file

@ -19,12 +19,12 @@ module Admin
format.json { render json: Track.where(state: :confirmed, program: @program).to_json } format.json { render json: Track.where(state: :confirmed, program: @program).to_json }
format.xlsx do format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\"" response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'tracks' render 'tracks', layout: false
end end
format.pdf { render 'tracks' } format.pdf { render 'tracks', layout: false }
format.csv do format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\"" response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'tracks' render 'tracks', layout: false
end end
end end
end end

View file

@ -1,4 +1,16 @@
- headers = ['Name', 'Email'] - headers = ['Attended',
'Name',
'Nickname',
'Affilιation',
'Email',
'Arrival',
'Departure']
= CSV.generate_line headers = CSV.generate_line headers
- @registrations.each do |registration| - @registrations.each do |registration|
= CSV.generate_line([registration.name, registration.email]) = CSV.generate_line([registration.attended ? 'X' : '',
registration.name,
registration.nickname,
registration.affiliation,
registration.email,
registration.arrival.to_s,
registration.departure.to_s])