From 140a50afde71c467bb77e619af8ac6b9a3ff6c59 Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 10 Apr 2019 17:01:28 +0530 Subject: [PATCH 1/4] install prawn-rails and remove prawn_rails Fixes https://github.com/openSUSE/osem/issues/2432 prawn_rails is removed and prawn-rails is added --- Gemfile | 2 +- Gemfile.lock | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index a1e081f6..52d9c21f 100644 --- a/Gemfile +++ b/Gemfile @@ -134,7 +134,7 @@ gem 'country_select' # as PDF generator gem 'prawn-qrcode' -gem 'prawn_rails' +gem 'prawn-rails' gem 'rqrcode' # to render XLS spreadsheets diff --git a/Gemfile.lock b/Gemfile.lock index 032fd182..af20b5d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -364,9 +364,12 @@ GEM prawn-qrcode (0.3.1) prawn (>= 1) rqrcode (>= 0.4.1) - prawn_rails (0.0.11) - prawn (>= 0.11.1) - railties (>= 3.0.0) + prawn-rails (1.2.0) + prawn + prawn-table + rails (>= 3.1.0) + prawn-table (0.2.2) + prawn (>= 1.3.0, < 3.0.0) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -669,7 +672,7 @@ DEPENDENCIES pg piwik_analytics (~> 1.0.1) prawn-qrcode - prawn_rails + prawn-rails puma (~> 3.0) rails (~> 5.0.7) rails-assets-bootstrap-markdown! From c27483301a25c03539253d92fc816b3cff8a6aaa Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 27 Mar 2019 19:12:50 +0530 Subject: [PATCH 2/4] add missing code for pdf csv xlsx in registrations --- app/controllers/admin/registrations_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 3f19ed39..89c4d069 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -15,12 +15,22 @@ module Admin @registration_distribution = @conference.registration_distribution @affiliation_distribution = @conference.affiliation_distribution @code_of_conduct = @conference.code_of_conduct.present? + @file_name = "registrations_for_#{@conference.short_title}" respond_to do |format| format.html format.json do render json: RegistrationDatatable.new(view_context, conference: @conference) 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 From a1a592dae3908109d323c2ebed8e51449a578d1c Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 27 Mar 2019 19:17:45 +0530 Subject: [PATCH 3/4] Fix view for registration csv --- app/views/admin/registrations/index.csv.haml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/admin/registrations/index.csv.haml b/app/views/admin/registrations/index.csv.haml index eace3122..76f01211 100644 --- a/app/views/admin/registrations/index.csv.haml +++ b/app/views/admin/registrations/index.csv.haml @@ -1,4 +1,16 @@ -- headers = ['Name', 'Email'] +- headers = ['Attended', + 'Name', + 'Nickname', + 'Affilιation', + 'Email', + 'Arrival', + 'Departure'] = CSV.generate_line headers - @registrations.each do |registration| - = CSV.generate_line([registration.name, registration.email]) \ No newline at end of file + = CSV.generate_line([registration.attended ? 'X' : '', + registration.name, + registration.nickname, + registration.affiliation, + registration.email, + registration.arrival.to_s, + registration.departure.to_s]) From d92f442685eff0a670f5fec60402e8b05ee2b525 Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 27 Mar 2019 23:28:38 +0530 Subject: [PATCH 4/4] add layout false to prevent default layout rendering layout false is added so that application.haml doesnt render while generating pdf, xlsx or csv as it is not required in their templates --- app/controllers/admin/booths_controller.rb | 6 +++--- app/controllers/admin/events_controller.rb | 6 +++--- app/controllers/admin/tracks_controller.rb | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/booths_controller.rb b/app/controllers/admin/booths_controller.rb index b39a2df4..aceceee0 100644 --- a/app/controllers/admin/booths_controller.rb +++ b/app/controllers/admin/booths_controller.rb @@ -14,12 +14,12 @@ module Admin format.json { render json: Booth.where(state: :confirmed, program: @program).to_json } format.xlsx do response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\"" - render 'booths' + render 'booths', layout: false end - format.pdf { render 'booths' } + format.pdf { render 'booths', layout: false } format.csv do response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\"" - render 'booths' + render 'booths', layout: false end end end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index bf579106..d8e9c1c9 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -28,12 +28,12 @@ module Admin format.json { render json: Event.where(state: :confirmed, program: @program).to_json } format.xlsx do response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\"" - render 'events' + render 'events', layout: false end - format.pdf { render 'events' } + format.pdf { render 'events', layout: false } format.csv do response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\"" - render 'events' + render 'events', layout: false end end end diff --git a/app/controllers/admin/tracks_controller.rb b/app/controllers/admin/tracks_controller.rb index 7d24e4a3..a4f4c69e 100644 --- a/app/controllers/admin/tracks_controller.rb +++ b/app/controllers/admin/tracks_controller.rb @@ -19,12 +19,12 @@ module Admin format.json { render json: Track.where(state: :confirmed, program: @program).to_json } format.xlsx do response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\"" - render 'tracks' + render 'tracks', layout: false end - format.pdf { render 'tracks' } + format.pdf { render 'tracks', layout: false } format.csv do response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\"" - render 'tracks' + render 'tracks', layout: false end end end