diff --git a/app/controllers/admin/booths_controller.rb b/app/controllers/admin/booths_controller.rb index 102eb10b..e41d11d3 100644 --- a/app/controllers/admin/booths_controller.rb +++ b/app/controllers/admin/booths_controller.rb @@ -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 diff --git a/app/controllers/admin/tracks_controller.rb b/app/controllers/admin/tracks_controller.rb index 7352ee35..4692f9a1 100644 --- a/app/controllers/admin/tracks_controller.rb +++ b/app/controllers/admin/tracks_controller.rb @@ -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| diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 3d549dfa..2ebbdeeb 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -4,4 +4,10 @@ class OrganizationsController < ApplicationController def index @organizations = Organization.all end + + def conferences + @current = @organization.conferences.upcoming.reorder(start_date: :asc) + @antiquated = @organization.conferences.past + render '/conferences/index' + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6174500e..f77d7963 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -171,4 +171,18 @@ module ApplicationHelper def hidden_if_conference_over(conference) 'hidden' if Date.today > conference.end_date end + + def nav_root_link_for(conference) + link_text = ( + conference.try(:organization).try(:name) || + ENV['OSEM_NAME'] || + 'OSEM' + ) + link_to( + link_text, + root_path, + class: 'navbar-brand', + title: 'Open Source Event Manager' + ) + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 18f9d4c4..b833b6f4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -15,7 +15,7 @@ class Ability # Abilities for not signed in users (guests) def not_signed_in - can [:index], Organization + can [:index, :conferences], Organization can [:index], Conference can [:show], Conference do |conference| conference.splashpage && conference.splashpage.public == true diff --git a/app/models/event.rb b/app/models/event.rb index c6de2d45..360421f5 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -204,11 +204,12 @@ class Event < ActiveRecord::Base end def speaker_names - result = Set.new - speakers.each do |speaker| - result.add(speaker.name) - end - result.to_a.to_sentence + speakers.map(&:name).join(', ') + end + + # Returns emails of all the speaker belongs to a particular event + def speaker_emails + speakers.map(&:email).join(', ') end ## diff --git a/app/views/admin/booths/_all_booths.csv.haml b/app/views/admin/booths/_all_booths.csv.haml new file mode 100644 index 00000000..7a6f10fd --- /dev/null +++ b/app/views/admin/booths/_all_booths.csv.haml @@ -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 diff --git a/app/views/admin/booths/_all_booths.pdf.prawn b/app/views/admin/booths/_all_booths.pdf.prawn new file mode 100644 index 00000000..168397e8 --- /dev/null +++ b/app/views/admin/booths/_all_booths.pdf.prawn @@ -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 diff --git a/app/views/admin/booths/_all_booths.xlsx.axlsx b/app/views/admin/booths/_all_booths.xlsx.axlsx new file mode 100644 index 00000000..bd1cc1db --- /dev/null +++ b/app/views/admin/booths/_all_booths.xlsx.axlsx @@ -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 diff --git a/app/views/admin/booths/_confirmed_booths.csv.haml b/app/views/admin/booths/_confirmed_booths.csv.haml new file mode 100644 index 00000000..b5d17eb4 --- /dev/null +++ b/app/views/admin/booths/_confirmed_booths.csv.haml @@ -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 diff --git a/app/views/admin/booths/_confirmed_booths.pdf.prawn b/app/views/admin/booths/_confirmed_booths.pdf.prawn new file mode 100644 index 00000000..a9750ab9 --- /dev/null +++ b/app/views/admin/booths/_confirmed_booths.pdf.prawn @@ -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 diff --git a/app/views/admin/booths/_confirmed_booths.xlsx.axlsx b/app/views/admin/booths/_confirmed_booths.xlsx.axlsx new file mode 100644 index 00000000..2dc10013 --- /dev/null +++ b/app/views/admin/booths/_confirmed_booths.xlsx.axlsx @@ -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 diff --git a/app/views/admin/booths/booths.csv.haml b/app/views/admin/booths/booths.csv.haml new file mode 100644 index 00000000..27d1d354 --- /dev/null +++ b/app/views/admin/booths/booths.csv.haml @@ -0,0 +1,4 @@ +- if @booth_export_option == 'confirmed' + = render 'confirmed_booths' +- elsif @booth_export_option == 'all' + = render 'all_booths' diff --git a/app/views/admin/booths/booths.pdf.prawn b/app/views/admin/booths/booths.pdf.prawn new file mode 100644 index 00000000..5c8f9bd2 --- /dev/null +++ b/app/views/admin/booths/booths.pdf.prawn @@ -0,0 +1,5 @@ +if @booth_export_option == 'confirmed' + render 'confirmed_booths' +elsif @booth_export_option == 'all' + render 'all_booths' +end diff --git a/app/views/admin/booths/booths.xlsx.axlsx b/app/views/admin/booths/booths.xlsx.axlsx new file mode 100644 index 00000000..5fe084db --- /dev/null +++ b/app/views/admin/booths/booths.xlsx.axlsx @@ -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 diff --git a/app/views/admin/booths/index.html.haml b/app/views/admin/booths/index.html.haml index 428895e5..431b6dfc 100644 --- a/app/views/admin/booths/index.html.haml +++ b/app/views/admin/booths/index.html.haml @@ -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 diff --git a/app/views/admin/events/_all_events.csv.haml b/app/views/admin/events/_all_events.csv.haml index 9423c4ee..c7bff3be 100644 --- a/app/views/admin/events/_all_events.csv.haml +++ b/app/views/admin/events/_all_events.csv.haml @@ -4,6 +4,7 @@ 'Start time', 'Submitter', 'Speaker', + 'Speaker Email', 'Event Type', 'Track', 'Difficulty Level', @@ -12,8 +13,15 @@ = CSV.generate_line ['All Events'] = CSV.generate_line headers - @events.each do |event| - = CSV.generate_line([event.id, event.title, event.abstract, (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : ''), - event.submitter.name, event.speaker_names, event.event_type.title, + = CSV.generate_line([event.id, + event.title, + event.abstract, + (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")}#{event.time.strftime("%I:%M%p")} " : ''), + event.submitter.name, + event.speaker_names, + event.speaker_emails, + event.event_type.title, (event.track.present? ? event.track.name : ''), (event.difficulty_level.present? ? event.difficulty_level.title : ''), - (event.room.present? ? event.room.name : ''), event.state]).html_safe + (event.room.present? ? event.room.name : ''), + event.state]).html_safe diff --git a/app/views/admin/events/_all_events.pdf.prawn b/app/views/admin/events/_all_events.pdf.prawn index e53a1018..3f1c0d78 100644 --- a/app/views/admin/events/_all_events.pdf.prawn +++ b/app/views/admin/events/_all_events.pdf.prawn @@ -6,6 +6,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: 'Start time', 'Submitter', 'Speaker', + 'Speaker Email', 'Event Type', 'Track', 'Difficulty Level', @@ -21,6 +22,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') row << event.submitter.name row << event.speaker_names + row << event.speaker_emails row << event.event_type.title row << (event.track.present? ? event.track.name : '') row << (event.difficulty_level.present? ? event.difficulty_level.title : '') @@ -30,5 +32,5 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: end pdf.text "#{@conference.short_title} Events", font_size: 25, align: :center - pdf.table events_array, header: true, cell_style: {size: 8, border_width: 1} + pdf.table events_array, header: true, cell_style: {size: 8, border_width: 1},column_widths: [40,60,90,50,70,65,85,50,55,50,60,45] end diff --git a/app/views/admin/events/_all_events.xlsx.axlsx b/app/views/admin/events/_all_events.xlsx.axlsx index 66232784..3197cf38 100644 --- a/app/views/admin/events/_all_events.xlsx.axlsx +++ b/app/views/admin/events/_all_events.xlsx.axlsx @@ -1,6 +1,18 @@ wb.add_worksheet(name: 'all events') do |sheet| bold_style = wb.styles.add_style(b: true) - row = ['Event ID', 'Title', 'Abstract', 'Start time', 'Submitter', 'Speaker', 'Event Type', 'Track', 'Difficulty Level', 'Room', 'State'] + wrap_text = wb.styles.add_style alignment: {wrap_text: true} + row = ['Event ID', + 'Title', + 'Abstract', + 'Start time', + 'Submitter', + 'Speaker', + 'Speaker Email', + 'Event Type', + 'Track', + 'Difficulty Level', + 'Room', + 'State'] sheet.add_row row, style: bold_style @events.each do |event| @@ -11,11 +23,13 @@ wb.add_worksheet(name: 'all events') do |sheet| row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') row << event.submitter.name row << event.speaker_names + row << event.speaker_emails row << event.event_type.title row << (event.track.present? ? event.track.name : '') row << (event.difficulty_level.present? ? event.difficulty_level.title : '') row << (event.room.present? ? event.room.name : '') row << event.state - sheet.add_row row + sheet.add_row row , style: wrap_text + sheet.column_widths 10,15,35,13,18,18,28,12,15,15,15,10 end end diff --git a/app/views/admin/events/_all_with_comments.csv.haml b/app/views/admin/events/_all_with_comments.csv.haml index cdf79339..315da41e 100644 --- a/app/views/admin/events/_all_with_comments.csv.haml +++ b/app/views/admin/events/_all_with_comments.csv.haml @@ -4,6 +4,7 @@ 'Start time', 'Submitter', 'Speaker', + 'Speaker Email', 'Event Type', 'Track', 'Difficulty Level', @@ -16,8 +17,17 @@ - all_comments = '' - event.root_comments.each do |comment| - all_comments << "#{comment.created_at.strftime("%Y-%m-%d")} #{comment.created_at.strftime("%I:%M%p")} #{comment.user.name}: #{comment.body}\n" - = CSV.generate_line([event.id, event.title, event.abstract, (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : ''), - event.submitter.name, event.speaker_names, event.event_type.title, + = CSV.generate_line([event.id, + event.title, + event.abstract, + (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")}#{event.time.strftime("%I:%M%p")} " : ''), + event.submitter.name, + event.speaker_names, + event.speaker_emails, + event.event_type.title, (event.track.present? ? event.track.name : ''), (event.difficulty_level.present? ? event.difficulty_level.title : ''), - (event.room.present? ? event.room.name : ''), event.state, all_comments]).html_safe + (event.room.present? ? event.room.name : ''), + event.state, + all_comments]).html_safe + diff --git a/app/views/admin/events/_all_with_comments.pdf.prawn b/app/views/admin/events/_all_with_comments.pdf.prawn index 2df27759..ccc9b773 100644 --- a/app/views/admin/events/_all_with_comments.pdf.prawn +++ b/app/views/admin/events/_all_with_comments.pdf.prawn @@ -6,6 +6,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: 'Start time', 'Submitter', 'Speaker', + 'Speaker Email', 'Event Type', 'Track', 'Difficulty Level', @@ -21,6 +22,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') row << event.submitter.name row << event.speaker_names + row << event.speaker_emails row << event.event_type.title row << (event.track.present? ? event.track.name : '') row << (event.difficulty_level.present? ? event.difficulty_level.title : '') @@ -31,7 +33,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: pdf.text "#{@conference.short_title} Events", font_size: 25, align: :center pdf.move_down 10 - pdf.table events_array, header: true, cell_style: {size: 8, border_width: 1, position: :center} + pdf.table events_array, header: true, cell_style: {size: 8, border_width: 1, position: :center},column_widths: [40,60,90,50,70,65,85,50,55,50,60,45] pdf.start_new_page pdf.text "#{@conference.short_title} Comments", font_size: 25, align: :center pdf.move_down 20 diff --git a/app/views/admin/events/_all_with_comments.xlsx.axlsx b/app/views/admin/events/_all_with_comments.xlsx.axlsx index 038dfea5..fd798ca5 100644 --- a/app/views/admin/events/_all_with_comments.xlsx.axlsx +++ b/app/views/admin/events/_all_with_comments.xlsx.axlsx @@ -1,8 +1,20 @@ wb.use_shared_strings = true wb.add_worksheet(name: 'events with comments') do |sheet| - bold_style = wb.styles.add_style(b: true ) + bold_style = wb.styles.add_style(b: true) cell_style = wb.styles.add_style(alignment: { wrap_text: true, vertical: :top }) -row = ['Event ID', 'Title', 'Abstract', 'Start time', 'Submitter', 'Speaker', 'Event Type', 'Track', 'Difficulty Level', 'Room', 'State', 'Comments'] + row = ['Event ID', + 'Title', + 'Abstract', + 'Start time', + 'Submitter', + 'Speaker', + 'Speaker Email', + 'Event Type', + 'Track', + 'Difficulty Level', + 'Room', + 'State', + 'Comments'] sheet.add_row row, style: bold_style @events.each do |event| @@ -17,6 +29,7 @@ row = ['Event ID', 'Title', 'Abstract', 'Start time', 'Submitter', 'Speaker', 'E row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') row << event.submitter.name row << event.speaker_names + row << event.speaker_emails row << event.event_type.title row << (event.track.present? ? event.track.name : '') row << (event.difficulty_level.present? ? event.difficulty_level.title : '') @@ -24,5 +37,6 @@ row = ['Event ID', 'Title', 'Abstract', 'Start time', 'Submitter', 'Speaker', 'E row << event.state row << all_comments.strip sheet.add_row row, style: cell_style + sheet.column_widths 10,15,35,13,18,18,28,12,15,15,15,10 end end diff --git a/app/views/admin/events/_confirmed_events.csv.haml b/app/views/admin/events/_confirmed_events.csv.haml index 4edbbaa3..2a61c352 100644 --- a/app/views/admin/events/_confirmed_events.csv.haml +++ b/app/views/admin/events/_confirmed_events.csv.haml @@ -4,6 +4,7 @@ 'Start time', 'Submitter', 'Speaker', + 'Speaker Email', 'Event Type', 'Track', 'Difficulty Level', @@ -12,8 +13,15 @@ = CSV.generate_line ["Confirmed Events"] = CSV.generate_line headers - @events.confirmed.each do |event| - = CSV.generate_line([event.id, event.title, event.abstract, (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : ''), - event.submitter.name, event.speaker_names, event.event_type.title, + = CSV.generate_line([event.id, + event.title, + event.abstract, + (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : ''), + event.submitter.name, + event.speaker_names, + event.speaker_emails, + event.event_type.title, (event.track.present? ? event.track.name : ''), (event.difficulty_level.present? ? event.difficulty_level.title : ''), - (event.room.present? ? event.room.name : ''), event.state]).html_safe + (event.room.present? ? event.room.name : ''), + event.state]).html_safe diff --git a/app/views/admin/events/_confirmed_events.pdf.prawn b/app/views/admin/events/_confirmed_events.pdf.prawn index ea838b94..8bef8883 100644 --- a/app/views/admin/events/_confirmed_events.pdf.prawn +++ b/app/views/admin/events/_confirmed_events.pdf.prawn @@ -6,6 +6,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: 'Start time', 'Submitter', 'Speaker', + 'Speaker Email', 'Event Type', 'Track', 'Difficulty Level', @@ -21,6 +22,7 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') row << event.submitter.name row << event.speaker_names + row << event.speaker_emails row << event.event_type.title row << (event.track.present? ? event.track.name : '') row << (event.difficulty_level.present? ? event.difficulty_level.title : '') @@ -30,6 +32,6 @@ prawn_document(force_download: true, filename: "#{@file_name}.pdf", page_layout: end pdf.text "#{@conference.short_title} Confirmed Events", font_size: 25, align: :center - pdf.table events_array, header: true, cell_style: {size: 8, border_width: 1} + pdf.table events_array, header: true, cell_style: {size: 8, border_width: 1},column_widths: [40,60,90,50,70,65,85,50,55,50,60,45] end diff --git a/app/views/admin/events/_confirmed_events.xlsx.axlsx b/app/views/admin/events/_confirmed_events.xlsx.axlsx index 34c40b36..a1c8c886 100644 --- a/app/views/admin/events/_confirmed_events.xlsx.axlsx +++ b/app/views/admin/events/_confirmed_events.xlsx.axlsx @@ -1,6 +1,18 @@ wb.add_worksheet(name: 'confirmed events') do |sheet| bold_style = wb.styles.add_style(b: true) - row = ['Event ID', 'Title', 'Abstract', 'Start time', 'Submitter', 'Speaker', 'Event Type', 'Track', 'Difficulty Level', 'Room', 'State'] + wrap_text = wb.styles.add_style alignment: {wrap_text: true} + row = ['Event ID', + 'Title', + 'Abstract', + 'Start time', + 'Submitter', + 'Speaker', + 'Speaker Email', + 'Event Type', + 'Track', + 'Difficulty Level', + 'Room', + 'State'] sheet.add_row row, style: bold_style @events.confirmed.each do |event| @@ -11,11 +23,13 @@ wb.add_worksheet(name: 'confirmed events') do |sheet| row << (event.time.present? ? "#{event.time.strftime("%Y-%m-%d")} #{event.time.strftime("%I:%M%p")} " : '') row << event.submitter.name row << event.speaker_names + row << event.speaker_emails row << event.event_type.title row << (event.track.present? ? event.track.name : '') row << (event.difficulty_level.present? ? event.difficulty_level.title : '') row << (event.room.present? ? event.room.name : '') row << event.state - sheet.add_row row + sheet.add_row row , style: wrap_text + sheet.column_widths 10,15,35,13,18,18,28,12,15,15,15,10 end end diff --git a/app/views/admin/tracks/_all_tracks.csv.haml b/app/views/admin/tracks/_all_tracks.csv.haml new file mode 100644 index 00000000..a2361231 --- /dev/null +++ b/app/views/admin/tracks/_all_tracks.csv.haml @@ -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 diff --git a/app/views/admin/tracks/_all_tracks.pdf.prawn b/app/views/admin/tracks/_all_tracks.pdf.prawn new file mode 100644 index 00000000..885c4d28 --- /dev/null +++ b/app/views/admin/tracks/_all_tracks.pdf.prawn @@ -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 diff --git a/app/views/admin/tracks/_all_tracks.xlsx.axlsx b/app/views/admin/tracks/_all_tracks.xlsx.axlsx new file mode 100644 index 00000000..d1397193 --- /dev/null +++ b/app/views/admin/tracks/_all_tracks.xlsx.axlsx @@ -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 diff --git a/app/views/admin/tracks/_confirmed_tracks.csv.haml b/app/views/admin/tracks/_confirmed_tracks.csv.haml new file mode 100644 index 00000000..b2bd3f85 --- /dev/null +++ b/app/views/admin/tracks/_confirmed_tracks.csv.haml @@ -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 diff --git a/app/views/admin/tracks/_confirmed_tracks.pdf.prawn b/app/views/admin/tracks/_confirmed_tracks.pdf.prawn new file mode 100644 index 00000000..290014a8 --- /dev/null +++ b/app/views/admin/tracks/_confirmed_tracks.pdf.prawn @@ -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 diff --git a/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx b/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx new file mode 100644 index 00000000..673b985c --- /dev/null +++ b/app/views/admin/tracks/_confirmed_tracks.xlsx.axlsx @@ -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 diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index b814ac8e..a5f5c9a0 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -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 diff --git a/app/views/admin/tracks/tracks.csv.haml b/app/views/admin/tracks/tracks.csv.haml new file mode 100644 index 00000000..a94811fe --- /dev/null +++ b/app/views/admin/tracks/tracks.csv.haml @@ -0,0 +1,4 @@ +- if @track_export_option == 'confirmed' + = render 'confirmed_tracks' +- elsif @track_export_option == 'all' + = render 'all_tracks' diff --git a/app/views/admin/tracks/tracks.pdf.prawn b/app/views/admin/tracks/tracks.pdf.prawn new file mode 100644 index 00000000..c74b3cbb --- /dev/null +++ b/app/views/admin/tracks/tracks.pdf.prawn @@ -0,0 +1,5 @@ +if @track_export_option == 'confirmed' + render 'confirmed_tracks' +elsif @track_export_option == 'all' + render 'all_tracks' +end diff --git a/app/views/admin/tracks/tracks.xlsx.axlsx b/app/views/admin/tracks/tracks.xlsx.axlsx new file mode 100644 index 00000000..6a84da9b --- /dev/null +++ b/app/views/admin/tracks/tracks.xlsx.axlsx @@ -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 diff --git a/app/views/conferences/index.html.haml b/app/views/conferences/index.html.haml index 032db5c3..a3735478 100644 --- a/app/views/conferences/index.html.haml +++ b/app/views/conferences/index.html.haml @@ -4,7 +4,7 @@ .page-header %h2 Upcoming Conferences - @current.each do |conference| - = render partial: 'conference_details', locals: { conference: conference } + = render '/conferences/conference_details', conference: conference -if @antiquated and @antiquated.any? .row .col-md-12 @@ -17,7 +17,7 @@ %i.fa.fa-chevron-down{ style: 'display: none' } #antiquated.collapse - @antiquated.each do |conference| - = render partial: 'conference_details', locals: { conference: conference} + = render '/conferences/conference_details', conference: conference -content_for :script_body do :javascript diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 9995123b..f7d5fa30 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -13,10 +13,8 @@ %span.icon-bar %span.icon-bar %span.icon-bar - - if conference.nil? || conference.new_record? - = link_to (ENV['OSEM_NAME'] || 'OSEM'), root_path, class: 'navbar-brand', title: 'Open Source Event Manager' - - else - = link_to conference.organization.name, organizations_path, class: 'navbar-brand', title: 'Open Source Event Manager' + = nav_root_link_for conference + .collapse.navbar-collapse#main-nav - if content_for :splash_nav %ul.nav.navbar-nav#splash-nav diff --git a/app/views/organizations/index.html.haml b/app/views/organizations/index.html.haml index b2794bd8..bc5a4d5e 100644 --- a/app/views/organizations/index.html.haml +++ b/app/views/organizations/index.html.haml @@ -12,5 +12,7 @@ .caption %h4 = organization.name - %button.btn.btn-success Conferences + = link_to 'Conferences', + conferences_organization_path(organization), + class: 'btn btn-success' / = link_to 'Edit', edit_organization_path(organization), class: 'btn btn-mini btn-default' diff --git a/app/views/proposals/index.html.haml b/app/views/proposals/index.html.haml index bc704296..97a721c0 100644 --- a/app/views/proposals/index.html.haml +++ b/app/views/proposals/index.html.haml @@ -67,7 +67,7 @@ %small.text-muted = event.event_type.title = "(#{event.event_type.length} min)" - = "in #{event.traistck.name}" if event.track + = "in #{event.track.name}" if event.track - if event.require_registration %br = link_to registered_text(event), registrations_conference_program_proposal_path(@conference.short_title, event), class: 'btn btn-xs btn-danger' diff --git a/bootstrap.sh b/bootstrap.sh index 92a8d746..06a642dd 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,10 @@ #!/bin/bash + +# set env os release variables +. /etc/os-release + +if [[ "$ID" == "opensuse" ]]; then + pushd /vagrant echo -e "\ninstalling required software packages...\n" @@ -14,6 +20,42 @@ echo 'install: --no-format-executable' >> /etc/gemrc echo -e "\ninstalling bundler...\n" gem.ruby2.4 install bundler +elif [[ "$ID" == "centos" || "$VERSION" == "7" ]]; then + _YELLOW='\033[1;33m' # yellow color + _LRED='\033[1;31m' # Light red color + _NO_COLOUR='\033[0m' # no color + + printf "${_YELLOW}CEntOS-7 Setup${_NO_COLOUR}\n" + + printf "${_YELLOW}installing ruby-2.4${_NO_COLOUR}\n" + yum install -q -y https://github.com/feedforce/ruby-rpm/releases/download/2.4.2/ruby-2.4.2-1.el7.centos.x86_64.rpm + if [[ ! "$?" -eq 0 ]]; then + printf "${_LRED}Error trying to install ruby-2.4${_NO_COLOUR}\n" + fi + + printf "${_YELLOW}installing ruby-2.4 gems dependencies${_NO_COLOUR}\n" + gem install bundler + if [[ ! "$?" -eq 0 ]]; then + printf "${_LRED}Error trying to install ruby-2.4 bundler${_NO_COLOUR}\n" + fi + + printf "${_YELLOW}installing nodejs repo${_NO_COLOUR}\n" + curl -sL https://rpm.nodesource.com/setup_9.x | bash - > /dev/null + + printf "${_YELLOW}installing nodejs and devel tools${_NO_COLOUR}\n" + yum install -q -y git make gcc gcc-c++ libxml2-devel libxslt-devel nodejs screen mariadb mariadb-devel sqlite-devel ImageMagick bzip2 + + # for production: bundle install --without test development + printf "${_YELLOW}Opening firewall port: 3000${_NO_COLOUR}\n" + iptables -I INPUT -p tcp --dport 3000 -j ACCEPT + + printf "${_YELLOW}installing phantomjs${_NO_COLOUR}\n" + curl -L --silent https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -o /tmp/phantomjs-2.1.1-linux-x86_64.tar.bz2 + tar jxvf /tmp/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /tmp/ phantomjs-2.1.1-linux-x86_64/bin/phantomjs + mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin + +fi + echo -e "\ninstalling your bundle...\n" su - vagrant -c "cd /vagrant/; bundle install --quiet" diff --git a/config/routes.rb b/config/routes.rb index 6e8a66de..33a92a48 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -149,7 +149,11 @@ Osem::Application.routes.draw do get '/revision_history/:id/revert_object' => 'versions#revert_object', as: 'revision_history_revert_object' get '/revision_history/:id/revert_attribute' => 'versions#revert_attribute', as: 'revision_history_revert_attribute' end - resources :organizations, only: [:index] + resources :organizations, only: [:index] do + member do + get :conferences + end + end resources :conferences, only: [:index, :show] do resources :booths do member do diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index 2916fdea..eb0109a1 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -2,6 +2,26 @@ require 'spec_helper' describe OrganizationsController do let!(:organization) { create(:organization) } + let!(:conference) do + create( + :conference, + splashpage: create(:splashpage, public: true), + venue: create(:venue), + organization: organization + ) + end + let!(:antiquated_conference) do + create( + :conference, + splashpage: create(:splashpage, public: true), + venue: create(:venue), + organization: organization, + start_date: 2.weeks.ago, + end_date: 1.week.ago + ) + end + + let!(:other_conference) { create(:conference) } let!(:user) { create(:user) } describe 'GET #index' do @@ -12,4 +32,27 @@ describe OrganizationsController do it { expect(response).to render_template('index') } end + + describe 'GET #conferences' do + before :each do + get :conferences, id: organization.id + end + + it 'loads the organization' do + expect(assigns(:organization)).to eq organization + end + + it 'includes organization conferences' do + expect(assigns(:current)).to include conference + end + + it 'does not include conferences outside organization' do + expect(assigns(:current)).not_to include other_conference + expect(assigns(:antiquated)).not_to include other_conference + end + + it 'includes antiquated organization conferences' do + expect(assigns(:antiquated)).to include antiquated_conference + end + end end diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb index 6fcf590b..72948c2d 100644 --- a/spec/features/organization_spec.rb +++ b/spec/features/organization_spec.rb @@ -48,4 +48,12 @@ feature Organization do it_behaves_like 'successfully updates an organization' end + + context 'anonymously' do + scenario 'index should link to conferences list' do + visit organizations_path + + expect(page).to have_link('Conferences', href: "/organizations/#{organization.id}/conferences") + end + end end diff --git a/spec/features/splashpage_spec.rb b/spec/features/splashpage_spec.rb index ee9b63d5..d33c6c85 100644 --- a/spec/features/splashpage_spec.rb +++ b/spec/features/splashpage_spec.rb @@ -62,14 +62,18 @@ feature Splashpage do end end - context 'public splashpage already created' do + context 'navigation' do let!(:splashpage) { create(:splashpage, conference: conference, public: true)} - scenario 'should have organization name', feature: true, js: true do - sign_in participant - visit conference_path(conference.short_title) + context 'multiple organizations' do + let!(:additional_organization) { create(:organization) } - expect(page).to have_text(conference.organization.name) + scenario 'should have organization name', feature: true, js: true do + sign_in participant + visit conference_path(conference.short_title) + + expect(page).to have_text(conference.organization.name) + end end end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 139a5cf9..6cd71d2a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -58,5 +58,21 @@ describe ApplicationHelper, type: :helper do expect(concurrent_events(event).present?).to eq false end end + + describe 'navigation title link' do + it 'should default to OSEM' do + ENV.delete('OSEM_NAME') + expect(nav_root_link_for(nil)).to match 'OSEM' + end + + it 'should use the environment variable' do + ENV['OSEM_NAME'] = Faker::Company.name + expect(nav_root_link_for(nil)).to match ENV['OSEM_NAME'] + end + + it 'should use the conference organization name' do + expect(nav_root_link_for(conference)).to match conference.organization.name + end + end end end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 0a84aedd..158e1db3 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -362,7 +362,7 @@ describe Event do new_event.submitter = submitter new_event.speakers = [speaker1, speaker2] - expect(new_event.speaker_names).to eq 'user speaker 1 and user speaker 2' + expect(new_event.speaker_names).to eq 'user speaker 1, user speaker 2' end end end