mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
export feature for tracks and booths are done
This commit is contained in:
parent
be1992a03a
commit
e99287d18a
22 changed files with 418 additions and 3 deletions
|
|
@ -3,7 +3,24 @@ module Admin
|
|||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource through: :conference
|
||||
|
||||
def index; end
|
||||
def index
|
||||
@file_name = "booths_for_#{@conference.short_title}"
|
||||
@booth_export_option = params[:booth_export_option]
|
||||
respond_to do |format|
|
||||
format.html
|
||||
# Explicity call #to_json to avoid the use of EventSerializer
|
||||
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'
|
||||
end
|
||||
format.pdf { render 'booths' }
|
||||
format.csv do
|
||||
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
|
||||
render 'booths'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,25 @@ module Admin
|
|||
# Show flash message with ajax calls
|
||||
after_action :prepare_unobtrusive_flash, only: :toggle_cfp_inclusion
|
||||
|
||||
def index; end
|
||||
def index
|
||||
@file_name = "tracks_for_#{@conference.short_title}"
|
||||
@track_export_option = params[:track_export_option]
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
# Explicity call #to_json to avoid the use of EventSerializer
|
||||
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'
|
||||
end
|
||||
format.pdf { render 'tracks' }
|
||||
format.csv do
|
||||
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
|
||||
render 'tracks'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
|
|
|
|||
19
app/views/admin/booths/_all_booths.csv.haml
Normal file
19
app/views/admin/booths/_all_booths.csv.haml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
- headers = ['Booth ID',
|
||||
'Title',
|
||||
'Description',
|
||||
'Reasoning',
|
||||
'Submitter Name',
|
||||
'Submitter Relationship',
|
||||
'Website Url',
|
||||
'State']
|
||||
= CSV.generate_line ['All booths']
|
||||
= CSV.generate_line headers
|
||||
- @booths.each do |booth|
|
||||
= CSV.generate_line([booth.id,
|
||||
booth.title,
|
||||
booth.description,
|
||||
booth.reasoning,
|
||||
booth.submitter.name,
|
||||
booth.submitter_relationship,
|
||||
booth.website_url,
|
||||
booth.state]).html_safe
|
||||
26
app/views/admin/booths/_all_booths.pdf.prawn
Normal file
26
app/views/admin/booths/_all_booths.pdf.prawn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: :landscape) do |pdf|
|
||||
booths_array = []
|
||||
header_array = ['Booth ID',
|
||||
'Title',
|
||||
'Description',
|
||||
'Reasoning',
|
||||
'Submitter Name',
|
||||
'Submitter Relationship',
|
||||
'Website Url',
|
||||
'State']
|
||||
booths_array << header_array
|
||||
@booths.each do |booth|
|
||||
row = []
|
||||
row << booth.id
|
||||
row << booth.title
|
||||
row << booth.description
|
||||
row << booth.reasoning
|
||||
row << booth.submitter.name
|
||||
row << booth.submitter_relationship
|
||||
row << booth.website_url
|
||||
row << booth.state
|
||||
booths_array << row
|
||||
end
|
||||
pdf.text "#{@conference.short_title} booths", font_size: 25, align: :center
|
||||
pdf.table booths_array, header: true, cell_style: {size: 8, border_width: 1},column_widths: [45,70,153,152,70,80,105,45]
|
||||
end
|
||||
27
app/views/admin/booths/_all_booths.xlsx.axlsx
Normal file
27
app/views/admin/booths/_all_booths.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
wb.add_worksheet(name: 'all booths') do |sheet|
|
||||
bold_style = wb.styles.add_style(b: true)
|
||||
wrap_text = wb.styles.add_style alignment: {wrap_text: true}
|
||||
row = ['Booth ID',
|
||||
'Title',
|
||||
'Description',
|
||||
'Reasoning',
|
||||
'Submitter Name',
|
||||
'Submitter Relationship',
|
||||
'Website Url',
|
||||
'State']
|
||||
|
||||
sheet.add_row row, style: bold_style
|
||||
@booths.each do |booth|
|
||||
row = []
|
||||
row << booth.id
|
||||
row << booth.title
|
||||
row << booth.description
|
||||
row << booth.reasoning
|
||||
row << booth.submitter.name
|
||||
row << booth.submitter_relationship
|
||||
row << booth.website_url
|
||||
row << booth.state
|
||||
sheet.add_row row , style: wrap_text
|
||||
sheet.column_widths 10,20,35,35,20,30,35,10
|
||||
end
|
||||
end
|
||||
19
app/views/admin/booths/_confirmed_booths.csv.haml
Normal file
19
app/views/admin/booths/_confirmed_booths.csv.haml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
- headers = ['Booth ID',
|
||||
'Title',
|
||||
'Description',
|
||||
'Reasoning',
|
||||
'Submitter Name',
|
||||
'Submitter Relationship',
|
||||
'Website Url',
|
||||
'State']
|
||||
= CSV.generate_line ['All booths']
|
||||
= CSV.generate_line headers
|
||||
- @booths.confirmed.each do |booth|
|
||||
= CSV.generate_line([booth.id,
|
||||
booth.title,
|
||||
booth.description,
|
||||
booth.reasoning,
|
||||
booth.submitter.name,
|
||||
booth.submitter_relationship,
|
||||
booth.website_url,
|
||||
booth.state]).html_safe
|
||||
26
app/views/admin/booths/_confirmed_booths.pdf.prawn
Normal file
26
app/views/admin/booths/_confirmed_booths.pdf.prawn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: :landscape) do |pdf|
|
||||
booths_array = []
|
||||
header_array = ['Booth ID',
|
||||
'Title',
|
||||
'Description',
|
||||
'Reasoning',
|
||||
'Submitter Name',
|
||||
'Submitter Relationship',
|
||||
'Website Url',
|
||||
'State']
|
||||
booths_array << header_array
|
||||
@booths.confirmed.each do |booth|
|
||||
row = []
|
||||
row << booth.id
|
||||
row << booth.title
|
||||
row << booth.description
|
||||
row << booth.reasoning
|
||||
row << booth.submitter.name
|
||||
row << booth.submitter_relationship
|
||||
row << booth.website_url
|
||||
row << booth.state
|
||||
booths_array << row
|
||||
end
|
||||
pdf.text "#{@conference.short_title} booths", font_size: 25, align: :center
|
||||
pdf.table booths_array, header: true, cell_style: {size: 8, border_width: 1},column_widths: [45,70,153,152,70,80,105,45]
|
||||
end
|
||||
27
app/views/admin/booths/_confirmed_booths.xlsx.axlsx
Normal file
27
app/views/admin/booths/_confirmed_booths.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
wb.add_worksheet(name: 'all booths') do |sheet|
|
||||
bold_style = wb.styles.add_style(b: true)
|
||||
wrap_text = wb.styles.add_style alignment: {wrap_text: true}
|
||||
row = ['Booth ID',
|
||||
'Title',
|
||||
'Description',
|
||||
'Reasoning',
|
||||
'Submitter Name',
|
||||
'Submitter Relationship',
|
||||
'Website Url',
|
||||
'State']
|
||||
sheet.add_row row, style: bold_style
|
||||
|
||||
@booths.confirmed.each do |booth|
|
||||
row = []
|
||||
row << booth.id
|
||||
row << booth.title
|
||||
row << booth.description
|
||||
row << booth.reasoning
|
||||
row << booth.submitter.name
|
||||
row << booth.submitter_relationship
|
||||
row << booth.website_url
|
||||
row << booth.state
|
||||
sheet.add_row row , style: wrap_text
|
||||
sheet.column_widths 10,20,35,35,20,30,35,10
|
||||
end
|
||||
end
|
||||
4
app/views/admin/booths/booths.csv.haml
Normal file
4
app/views/admin/booths/booths.csv.haml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
- if @booth_export_option == 'confirmed'
|
||||
= render 'confirmed_booths'
|
||||
- elsif @booth_export_option == 'all'
|
||||
= render 'all_booths'
|
||||
5
app/views/admin/booths/booths.pdf.prawn
Normal file
5
app/views/admin/booths/booths.pdf.prawn
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if @booth_export_option == 'confirmed'
|
||||
render 'confirmed_booths'
|
||||
elsif @booth_export_option == 'all'
|
||||
render 'all_booths'
|
||||
end
|
||||
7
app/views/admin/booths/booths.xlsx.axlsx
Normal file
7
app/views/admin/booths/booths.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
wb = xlsx_package.workbook
|
||||
xlsx_package.use_autowidth = true
|
||||
if @booth_export_option == 'confirmed'
|
||||
render partial: 'confirmed_booths', locals: { wb: wb }
|
||||
elsif @booth_export_option == 'all'
|
||||
render partial: 'all_booths', locals: { wb: wb }
|
||||
end
|
||||
|
|
@ -3,6 +3,30 @@
|
|||
.page-header
|
||||
%h1
|
||||
Booths
|
||||
.pull-right
|
||||
- if can? :read, Booth
|
||||
.btn-group
|
||||
.btn-group
|
||||
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
|
||||
Export PDF
|
||||
%span.caret
|
||||
%ul.dropdown-menu{ role: 'menu' }
|
||||
%li= link_to 'All Booths', admin_conference_booths_path(@conference.short_title, format: :pdf, booth_export_option: 'all')
|
||||
%li= link_to 'Confirmed Booths', admin_conference_booths_path(@conference.short_title, format: :pdf, booth_export_option: 'confirmed')
|
||||
.btn-group
|
||||
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
|
||||
Export CSV
|
||||
%span.caret
|
||||
%ul.dropdown-menu{ role: 'menu' }
|
||||
%li= link_to 'All', admin_conference_booths_path(@conference.short_title, format: :csv, booth_export_option: 'all')
|
||||
%li= link_to 'Confirmed', admin_conference_booths_path(@conference.short_title, format: :csv, booth_export_option: 'confirmed')
|
||||
.btn-group
|
||||
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
|
||||
Export XLS
|
||||
%span.caret
|
||||
%ul.dropdown-menu{ role: 'menu' }
|
||||
%li= link_to 'All', admin_conference_booths_path(@conference.short_title, format: :xlsx, booth_export_option: 'all')
|
||||
%li= link_to 'Confirmed', admin_conference_booths_path(@conference.short_title, format: :xlsx, booth_export_option: 'confirmed')
|
||||
= "(#{@booths.length})" if @booths.any?
|
||||
%p.text-muted
|
||||
All the booth requests
|
||||
|
|
|
|||
21
app/views/admin/tracks/_all_tracks.csv.haml
Normal file
21
app/views/admin/tracks/_all_tracks.csv.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
- headers = ['Track ID',
|
||||
'Name',
|
||||
'Description',
|
||||
'Room',
|
||||
'Start Date',
|
||||
'Start Date',
|
||||
'Submitter Name',
|
||||
'Included in Cfp',
|
||||
'State']
|
||||
= CSV.generate_line ['All Tracks']
|
||||
= CSV.generate_line headers
|
||||
- @tracks.each do |track|
|
||||
= CSV.generate_line([track.id,
|
||||
track.name,
|
||||
track.description,
|
||||
track.try(:room).try(:name),
|
||||
track.start_date,
|
||||
track.end_date,
|
||||
track.try(:submitter).try(:name),
|
||||
track.cfp_active? ? 'Yes' : 'No',
|
||||
track.state]).html_safe
|
||||
28
app/views/admin/tracks/_all_tracks.pdf.prawn
Normal file
28
app/views/admin/tracks/_all_tracks.pdf.prawn
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: :landscape) do |pdf|
|
||||
tracks_array = []
|
||||
header_array = ['Track ID',
|
||||
'Name',
|
||||
'Description',
|
||||
'Room',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Submitter Name',
|
||||
'Included in Cfp',
|
||||
'State']
|
||||
tracks_array << header_array
|
||||
@tracks.each do |track|
|
||||
row = []
|
||||
row << track.id
|
||||
row << track.name.to_s
|
||||
row << track.description.to_s
|
||||
row << track.try(:room).try(:name)
|
||||
row << track.start_date.to_s
|
||||
row << track.end_date.to_s
|
||||
row << track.try(:submitter).try(:name)
|
||||
row << (track.cfp_active? ? 'Yes' : 'No')
|
||||
row << track.state
|
||||
tracks_array << row
|
||||
end
|
||||
pdf.text "#{@conference.short_title} tracks", font_size: 25, align: :center
|
||||
pdf.table tracks_array, header: true, cell_style: {size: 8, border_width: 1},column_widths: [40,70,230,65,55,55,90,65,50]
|
||||
end
|
||||
29
app/views/admin/tracks/_all_tracks.xlsx.axlsx
Normal file
29
app/views/admin/tracks/_all_tracks.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
wb.add_worksheet(name: 'all tracks') do |sheet|
|
||||
bold_style = wb.styles.add_style(b: true)
|
||||
wrap_text = wb.styles.add_style alignment: {wrap_text: true}
|
||||
row = ['Track ID',
|
||||
'Name',
|
||||
'Description',
|
||||
'Room',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Submitter Name',
|
||||
'Included in Cfp',
|
||||
'State']
|
||||
sheet.add_row row, style: bold_style
|
||||
|
||||
@tracks.each do |track|
|
||||
row = []
|
||||
row << track.id
|
||||
row << track.name.to_s
|
||||
row << track.description.to_s
|
||||
row << track.try(:room).try(:name)
|
||||
row << track.start_date.to_s
|
||||
row << track.end_date.to_s
|
||||
row << track.try(:submitter).try(:name)
|
||||
row << (track.cfp_active? ? 'Yes' : 'No')
|
||||
row << track.state
|
||||
sheet.add_row row , style: wrap_text
|
||||
sheet.column_widths 10,20,50,20,12,12,20,15,10
|
||||
end
|
||||
end
|
||||
21
app/views/admin/tracks/_confirmed_tracks.csv.haml
Normal file
21
app/views/admin/tracks/_confirmed_tracks.csv.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
- headers = ['Track ID',
|
||||
'Name',
|
||||
'Description',
|
||||
'Room',
|
||||
'Start Date',
|
||||
'Start Date',
|
||||
'Submitter Name',
|
||||
'Included in Cfp',
|
||||
'State']
|
||||
= CSV.generate_line ['Confirmed Tracks']
|
||||
= CSV.generate_line headers
|
||||
- @tracks.confirmed.each do |track|
|
||||
= CSV.generate_line([track.id,
|
||||
track.name,
|
||||
track.description,
|
||||
track.try(:room).try(:name),
|
||||
track.start_date,
|
||||
track.end_date,
|
||||
track.try(:submitter).try(:name),
|
||||
track.cfp_active? ? 'Yes' : 'No',
|
||||
track.state]).html_safe
|
||||
28
app/views/admin/tracks/_confirmed_tracks.pdf.prawn
Normal file
28
app/views/admin/tracks/_confirmed_tracks.pdf.prawn
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: :landscape) do |pdf|
|
||||
tracks_array = []
|
||||
header_array = ['Track ID',
|
||||
'Name',
|
||||
'Description',
|
||||
'Room',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Submitter Name',
|
||||
'Included in Cfp',
|
||||
'State']
|
||||
tracks_array << header_array
|
||||
@tracks.confirmed.each do |track|
|
||||
row = []
|
||||
row << track.id
|
||||
row << track.name.to_s
|
||||
row << track.description.to_s
|
||||
row << track.try(:room).try(:name)
|
||||
row << track.start_date.to_s
|
||||
row << track.end_date.to_s
|
||||
row << track.try(:submitter).try(:name)
|
||||
row << (track.cfp_active? ? 'Yes' : 'No')
|
||||
row << track.state
|
||||
tracks_array << row
|
||||
end
|
||||
pdf.text "#{@conference.short_title} tracks", font_size: 25, align: :center
|
||||
pdf.table tracks_array, header: true, cell_style: {size: 8, border_width: 1},column_widths: [40,70,230,65,55,55,90,65,50]
|
||||
end
|
||||
29
app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx
Normal file
29
app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
wb.add_worksheet(name: 'all tracks') do |sheet|
|
||||
bold_style = wb.styles.add_style(b: true)
|
||||
wrap_text = wb.styles.add_style alignment: {wrap_text: true}
|
||||
row = ['Track ID',
|
||||
'Name',
|
||||
'Description',
|
||||
'Room',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Submitter Name',
|
||||
'Included in Cfp',
|
||||
'State']
|
||||
sheet.add_row row, style: bold_style
|
||||
|
||||
@tracks.confirmed.each do |track|
|
||||
row = []
|
||||
row << track.id
|
||||
row << track.name.to_s
|
||||
row << track.description.to_s
|
||||
row << track.try(:room).try(:name)
|
||||
row << track.start_date.to_s
|
||||
row << track.end_date.to_s
|
||||
row << track.try(:submitter).try(:name)
|
||||
row << (track.cfp_active? ? 'Yes' : 'No')
|
||||
row << track.state
|
||||
sheet.add_row row , style: wrap_text
|
||||
sheet.column_widths 10,20,50,20,12,12,20,15,10
|
||||
end
|
||||
end
|
||||
|
|
@ -2,7 +2,32 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1 Tracks
|
||||
%h1
|
||||
Tracks
|
||||
.pull-right
|
||||
- if can? :read, Track
|
||||
.btn-group
|
||||
.btn-group
|
||||
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
|
||||
Export PDF
|
||||
%span.caret
|
||||
%ul.dropdown-menu{ role: 'menu' }
|
||||
%li= link_to 'All Tracks', admin_conference_program_tracks_path(@conference.short_title, format: :pdf, track_export_option: 'all')
|
||||
%li= link_to 'Confirmed Tracks', admin_conference_program_tracks_path(@conference.short_title, format: :pdf, track_export_option: 'confirmed')
|
||||
.btn-group
|
||||
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
|
||||
Export CSV
|
||||
%span.caret
|
||||
%ul.dropdown-menu{ role: 'menu' }
|
||||
%li= link_to 'All', admin_conference_program_tracks_path(@conference.short_title, format: :csv, track_export_option: 'all')
|
||||
%li= link_to 'Confirmed', admin_conference_program_tracks_path(@conference.short_title, format: :csv, track_export_option: 'confirmed')
|
||||
.btn-group
|
||||
%button.btn.btn-default.dropdown-toggle{ 'data-toggle' => 'dropdown', type: 'button', class: 'btn btn-success' }
|
||||
Export XLS
|
||||
%span.caret
|
||||
%ul.dropdown-menu{ role: 'menu' }
|
||||
%li= link_to 'All', admin_conference_program_tracks_path(@conference.short_title, format: :xlsx, track_export_option: 'all')
|
||||
%li= link_to 'Confirmed', admin_conference_program_tracks_path(@conference.short_title, format: :xlsx, track_export_option: 'confirmed')
|
||||
%p.text-muted
|
||||
Categorize events in your conference
|
||||
.row
|
||||
|
|
|
|||
4
app/views/admin/tracks/tracks.csv.haml
Normal file
4
app/views/admin/tracks/tracks.csv.haml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
- if @track_export_option == 'confirmed'
|
||||
= render 'confirmed_tracks'
|
||||
- elsif @track_export_option == 'all'
|
||||
= render 'all_tracks'
|
||||
5
app/views/admin/tracks/tracks.pdf.prawn
Normal file
5
app/views/admin/tracks/tracks.pdf.prawn
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if @track_export_option == 'confirmed'
|
||||
render 'confirmed_tracks'
|
||||
elsif @track_export_option == 'all'
|
||||
render 'all_tracks'
|
||||
end
|
||||
6
app/views/admin/tracks/tracks.xlsx.axlsx
Normal file
6
app/views/admin/tracks/tracks.xlsx.axlsx
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
wb = xlsx_package.workbook
|
||||
if @track_export_option == 'confirmed'
|
||||
render partial: 'confirmed_tracks', locals: { wb: wb }
|
||||
elsif @track_export_option == 'all'
|
||||
render partial: 'all_tracks', locals: { wb: wb }
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue