xlsx export for registrations list
This commit is contained in:
parent
b9cd54a256
commit
9af4393928
6 changed files with 47 additions and 13 deletions
2
Gemfile
2
Gemfile
|
|
@ -51,4 +51,4 @@ gem 'prawn'
|
||||||
gem 'prawn_rails'
|
gem 'prawn_rails'
|
||||||
gem 'gravtastic'
|
gem 'gravtastic'
|
||||||
gem 'active_model_serializers'
|
gem 'active_model_serializers'
|
||||||
|
gem 'axlsx_rails'
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,13 @@ GEM
|
||||||
arel (3.0.2)
|
arel (3.0.2)
|
||||||
awesome_nested_set (2.1.6)
|
awesome_nested_set (2.1.6)
|
||||||
activerecord (>= 3.0.0)
|
activerecord (>= 3.0.0)
|
||||||
|
axlsx (1.3.6)
|
||||||
|
htmlentities (~> 4.3.1)
|
||||||
|
nokogiri (>= 1.4.1)
|
||||||
|
rubyzip (>= 0.9.5)
|
||||||
|
axlsx_rails (0.1.4)
|
||||||
|
axlsx
|
||||||
|
rails (>= 3.1)
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
bootstrap-sass (2.3.2.0)
|
bootstrap-sass (2.3.2.0)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
|
|
@ -80,6 +87,7 @@ GEM
|
||||||
tilt
|
tilt
|
||||||
hashery (2.1.0)
|
hashery (2.1.0)
|
||||||
hike (1.2.2)
|
hike (1.2.2)
|
||||||
|
htmlentities (4.3.1)
|
||||||
i18n (0.6.4)
|
i18n (0.6.4)
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
jquery-fileupload-rails (0.4.1)
|
jquery-fileupload-rails (0.4.1)
|
||||||
|
|
@ -217,6 +225,7 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
active_model_serializers
|
active_model_serializers
|
||||||
acts_as_commentable_with_threading
|
acts_as_commentable_with_threading
|
||||||
|
axlsx_rails
|
||||||
bcrypt-ruby (~> 3.0.0)
|
bcrypt-ruby (~> 3.0.0)
|
||||||
bootstrap-sass
|
bootstrap-sass
|
||||||
cancan
|
cancan
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,8 @@ class Admin::RegistrationsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
session[:return_to] ||= request.referer
|
session[:return_to] ||= request.referer
|
||||||
@pdf_filename = "#{@conference.title}.pdf"
|
@pdf_filename = "#{@conference.title}.pdf"
|
||||||
@registrations = @conference.registrations.all(:joins => :person,
|
@registrations = @conference.registrations.includes(:person).order("registrations.created_at ASC")
|
||||||
:order => "registrations.created_at ASC",
|
@attended = @conference.registrations.where("attended = ?", true).count
|
||||||
:select => "registrations.*,
|
|
||||||
people.last_name AS last_name,
|
|
||||||
people.first_name AS first_name,
|
|
||||||
people.public_name AS public_name,
|
|
||||||
people.email AS email")
|
|
||||||
|
|
||||||
@attended = @conference.registrations.where("attended = ?", true)
|
|
||||||
@headers = %w[attended name email attending_social_events attending_with_partner need_access other_needs arrival departure]
|
@headers = %w[attended name email attending_social_events attending_with_partner need_access other_needs arrival departure]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,13 @@ class Registration < ActiveRecord::Base
|
||||||
accepts_nested_attributes_for :person
|
accepts_nested_attributes_for :person
|
||||||
accepts_nested_attributes_for :supporter_registration
|
accepts_nested_attributes_for :supporter_registration
|
||||||
accepts_nested_attributes_for :social_events
|
accepts_nested_attributes_for :social_events
|
||||||
|
|
||||||
|
delegate :first_name, :to => :person
|
||||||
|
delegate :last_name, :to => :person
|
||||||
|
delegate :public_name, :to => :person
|
||||||
|
delegate :email, :to => :person
|
||||||
|
delegate :irc_nickname, :to => :person
|
||||||
|
delegate :company, :to => :person
|
||||||
|
|
||||||
alias_attribute :with_partner, :attending_with_partner
|
alias_attribute :with_partner, :attending_with_partner
|
||||||
alias_attribute :need_access, :handicapped_access_required
|
alias_attribute :need_access, :handicapped_access_required
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
.pull-right{:style=>"margin-top:20px; margin-bottom:20px;"}
|
.pull-right{:style=>"margin-top:20px; margin-bottom:20px;"}
|
||||||
= link_to "New", admin_users_new_path(@conference.short_title), :class => "btn btn-primary"
|
= link_to "New", admin_users_new_path(@conference.short_title), :class => "btn btn-primary"
|
||||||
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-success"
|
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-success"
|
||||||
|
= link_to "Export xlsx", {:format => :xlsx}, :class => "btn btn-success"
|
||||||
.row-fluid
|
.row-fluid
|
||||||
.span12
|
.span12
|
||||||
%h2
|
%h2
|
||||||
Registrations
|
Registrations
|
||||||
- if @registrations
|
- if @registrations
|
||||||
= "(#{@registrations.length})"
|
= "(#{@registrations.length})"
|
||||||
- if @attended
|
= " - Attended (#{@attended})"
|
||||||
= " - Attended (#{@attended.length})"
|
|
||||||
%table.table.table-striped.table-bordered.table-hover#registrations
|
%table.table.table-striped.table-bordered.table-hover#registrations
|
||||||
%thead
|
%thead
|
||||||
%th
|
%th
|
||||||
|
|
@ -49,4 +49,4 @@
|
||||||
"bPaginate": false,
|
"bPaginate": false,
|
||||||
"bLengthChange": false
|
"bLengthChange": false
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
||||||
25
app/views/admin/registrations/show.xlsx.axlsx
Normal file
25
app/views/admin/registrations/show.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
wb = xlsx_package.workbook
|
||||||
|
wb.add_worksheet(:name => "registrations") do |sheet|
|
||||||
|
bold_style = wb.styles.add_style(:b => true)
|
||||||
|
row = ["Attended", "Name", "Nickname", "Affilation", "Email", "Social events",
|
||||||
|
"With partner", "Needs access", "Other needs", "Arrival", "Departure"]
|
||||||
|
sheet.add_row row, :style => bold_style
|
||||||
|
|
||||||
|
@registrations.each do |reg|
|
||||||
|
row = []
|
||||||
|
row << reg.attended
|
||||||
|
row << "#{reg.last_name} #{reg.first_name} (#{reg.public_name})"
|
||||||
|
row << reg.irc_nickname
|
||||||
|
row << reg.company
|
||||||
|
row << reg.email
|
||||||
|
row << reg.attending_social_events
|
||||||
|
row << reg.attending_with_partner
|
||||||
|
row << reg.need_access
|
||||||
|
row << reg.other_needs
|
||||||
|
row << reg.arrival
|
||||||
|
row << reg.departure
|
||||||
|
sheet.add_row row
|
||||||
|
end
|
||||||
|
sheet.column_info[8].width = [sheet.column_info[8].width, 30].min
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue