Merge pull request #646 from differentreality/questions_users
show users per question
This commit is contained in:
commit
8accc47bcc
6 changed files with 80 additions and 38 deletions
|
|
@ -10,6 +10,10 @@ module Admin
|
||||||
@new_question = @conference.questions.new
|
@new_question = @conference.questions.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@registrations = @conference.registrations.joins(:qanswers).uniq
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@question = Question.new(conference_id: @conference.id)
|
@question = Question.new(conference_id: @conference.id)
|
||||||
authorize! :create, @question
|
authorize! :create, @question
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class Registration < ActiveRecord::Base
|
||||||
delegate :email, to: :user
|
delegate :email, to: :user
|
||||||
delegate :nickname, to: :user
|
delegate :nickname, to: :user
|
||||||
delegate :affiliation, to: :user
|
delegate :affiliation, to: :user
|
||||||
|
delegate :username, to: :user
|
||||||
|
|
||||||
alias_attribute :other_needs, :other_special_needs
|
alias_attribute :other_needs, :other_special_needs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
|
= link_to 'Show', admin_conference_question_path(@conference.short_title, q), class: 'btn btn-success'
|
||||||
= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
|
= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
|
||||||
class: 'btn btn-primary', disabled: !(can? :update, q)
|
class: 'btn btn-primary', disabled: !(can? :update, q)
|
||||||
= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
|
= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
|
||||||
|
|
|
||||||
26
app/views/admin/questions/show.html.haml
Normal file
26
app/views/admin/questions/show.html.haml
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
.container
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.page-header
|
||||||
|
%h1= @question.title
|
||||||
|
- @question.answers.each do |answer|
|
||||||
|
= answer.title
|
||||||
|
(#{answer.qanswers.find_by(question: @question).registrations.where(conference: @conference).count})
|
||||||
|
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
|
||||||
|
%table.table.table-border.table-hover.datatable#question_users
|
||||||
|
%thead
|
||||||
|
%th Name
|
||||||
|
%th Username
|
||||||
|
%th Email
|
||||||
|
%th Answer
|
||||||
|
%tbody
|
||||||
|
- @registrations.each do |registration|
|
||||||
|
%tr
|
||||||
|
%td= registration.name
|
||||||
|
%td= registration.username
|
||||||
|
%td= registration.email
|
||||||
|
%td= registration.qanswers.find_by(question: @question).answer.title
|
||||||
|
|
@ -1,34 +1,37 @@
|
||||||
prawn_document(:force_download=>true, :filename => @pdf_filename) do |pdf|
|
prawn_document(force_download: true, filename: @pdf_filename, page_layout: :landscape) do |pdf|
|
||||||
table_array = []
|
table_array = []
|
||||||
header_array = [" ",
|
header_array = ['Attended',
|
||||||
"Name",
|
'Name',
|
||||||
"Email",
|
'Nickname',
|
||||||
"Attending Social Events",
|
'Affiliation',
|
||||||
"Attending With Partner",
|
'Email',
|
||||||
"Arrival Date",
|
'Arrival Date',
|
||||||
"Departure Date"]
|
'Departure Date']
|
||||||
|
@conference.questions.each do |question|
|
||||||
|
header_array << question.title
|
||||||
|
end
|
||||||
|
|
||||||
table_array << header_array
|
table_array << header_array
|
||||||
@registrations.each do |registration|
|
@registrations.each do |registration|
|
||||||
row = []
|
row = []
|
||||||
row << ""
|
row << ( registration.attended ? 'X' : '' )
|
||||||
row << registration.name
|
row << registration.name
|
||||||
|
row << registration.nickname
|
||||||
|
row << registration.affiliation
|
||||||
row << registration.email
|
row << registration.email
|
||||||
if registration.attending_social_events
|
row << registration.arrival.to_s || ''
|
||||||
row << "X"
|
row << registration.departure.to_s || ''
|
||||||
else
|
|
||||||
row << " "
|
@conference.questions.each do |question|
|
||||||
|
qa = registration.qanswers.find_by(question: question)
|
||||||
|
answer = ( qa ? qa.answer.title : '' )
|
||||||
|
|
||||||
|
row << answer
|
||||||
end
|
end
|
||||||
|
|
||||||
if registration.attending_with_partner.to_s
|
|
||||||
row << "X"
|
|
||||||
else
|
|
||||||
row << " "
|
|
||||||
end
|
|
||||||
row << registration.arrival.to_s
|
|
||||||
row << registration.departure.to_s
|
|
||||||
table_array << row
|
table_array << row
|
||||||
end
|
end
|
||||||
|
|
||||||
pdf.text "#{@conference.title} Registrations", :font_size => 25
|
pdf.text "#{@conference.title} Registrations", font_size: 25
|
||||||
pdf.table table_array, :header => true, :cell_style => {:size => 5, :border_width => 1}
|
pdf.table table_array, header: true, cell_style: {size: 5, border_width: 1}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,30 @@
|
||||||
wb = xlsx_package.workbook
|
wb = xlsx_package.workbook
|
||||||
wb.add_worksheet(:name => "registrations") do |sheet|
|
wb.add_worksheet(name: 'registrations') do |sheet|
|
||||||
bold_style = wb.styles.add_style(:b => true)
|
bold_style = wb.styles.add_style(b: true)
|
||||||
row = ["Attended", "Name", "Nickname", "Affilation", "Email", "Social events",
|
row = ['Attended', 'Name', 'Nickname', 'Affilιation', 'Email', 'Arrival', 'Departure']
|
||||||
"With partner", "Needs access", "Other needs", "Arrival", "Departure"]
|
|
||||||
|
@conference.questions.each do |question|
|
||||||
|
row << question.title
|
||||||
|
end
|
||||||
|
|
||||||
sheet.add_row row, :style => bold_style
|
sheet.add_row row, :style => bold_style
|
||||||
|
|
||||||
@registrations.each do |reg|
|
@registrations.each do |registration|
|
||||||
row = []
|
row = []
|
||||||
row << reg.attended
|
row << ( registration.attended ? 'X' : '' )
|
||||||
row << reg.name
|
row << registration.name
|
||||||
row << reg.nickname
|
row << registration.nickname
|
||||||
row << reg.affiliation
|
row << registration.affiliation
|
||||||
row << reg.email
|
row << registration.email
|
||||||
row << reg.attending_social_events
|
row << registration.arrival.to_s
|
||||||
row << reg.attending_with_partner
|
row << registration.departure.to_s
|
||||||
row << reg.handicapped_access_required
|
@conference.questions.each do |question|
|
||||||
row << reg.other_needs
|
qa = registration.qanswers.find_by(question: question)
|
||||||
row << reg.arrival
|
answer = ( qa ? qa.answer.title : '' )
|
||||||
row << reg.departure
|
|
||||||
|
row << answer
|
||||||
|
end
|
||||||
|
|
||||||
sheet.add_row row
|
sheet.add_row row
|
||||||
end
|
end
|
||||||
sheet.column_info[8].width = [sheet.column_info[8].width, 30].min
|
sheet.column_info[8].width = [sheet.column_info[8].width, 30].min
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue