diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index f141529d..e5626aa1 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -9,19 +9,44 @@ class ConferencesController < ApplicationController end def show - @conference = if params[:id] - Conference.find_by_short_title(params[:id]) - else - load_conference_by_domain - end + @conference = Conference.unscoped.eager_load( + :organization, + :splashpage, + :venue, + :registration_period, + :tickets, + :confirmed_tracks, + :call_for_events, + :event_types, + :program, + :call_for_tracks, + :lodgings, + :call_for_booths, + :confirmed_booths, + :sponsors, + :call_for_sponsors, + :contact, + highlighted_events: [:speakers], + sponsorship_levels: [:sponsors] + ).order( + 'sponsorship_levels.position ASC', + 'sponsors.name', + 'tracks.name', + 'booths.title', + 'lodgings.name', + 'tickets.price_cents' + ).find_by(conference_finder_conditions) authorize! :show, @conference - @program = @conference.program end private - def load_conference_by_domain - Conference.find_by(custom_domain: request.domain) + def conference_finder_conditions + if params[:id] + { short_title: params[:id] } + else + { custom_domain: request.domain } + end end def respond_to_options diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9497cb1c..77f4f85e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -56,17 +56,7 @@ module ApplicationHelper end def tracks(conference) - all = conference.program.tracks.confirmed.cfp_active.pluck(:name) - first = all[0...-1] - last = all[-1] - ts = '' - if all.length > 1 - ts << first.join(', ') - ts << " and #{last}" - else - ts = all.join - end - ts + conference.confirmed_tracks.collect(&:name).to_sentence end def difficulty_levels(conference) @@ -152,7 +142,7 @@ module ApplicationHelper end def event_types(conference) - conference.program.event_types.map { |et| et.title.pluralize }.to_sentence + conference.event_types.map { |et| et.title.pluralize }.to_sentence end def sign_in_path diff --git a/app/models/conference.rb b/app/models/conference.rb index b12137d8..cb319d32 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -33,6 +33,7 @@ class Conference < ApplicationRecord end has_many :resources, dependent: :destroy has_many :booths, dependent: :destroy + has_many :confirmed_booths, -> { where(state: 'confirmed') }, class_name: 'Booth' has_many :lodgings, dependent: :destroy has_many :registrations, dependent: :destroy @@ -45,7 +46,16 @@ class Conference < ApplicationRecord has_many :campaigns, dependent: :destroy has_many :commercials, as: :commercialable, dependent: :destroy has_many :subscriptions, dependent: :destroy - + has_one :call_for_sponsors, -> { where(cfp_type: 'sponsors') }, through: :program, source: :cfps + has_one :call_for_events, -> { where(cfp_type: 'events') }, through: :program, source: :cfps + has_one :call_for_booths, -> { where(cfp_type: 'booths') }, through: :program, source: :cfps + has_one :call_for_tracks, -> { where(cfp_type: 'tracks') }, through: :program, source: :cfps + has_many :confirmed_tracks, -> { where(state: 'confirmed') }, through: :program, source: :tracks + has_many :highlighted_events, + -> { where(state: :confirmed, is_highlight: true) }, + through: :program, + source: :events + has_many :event_types, through: :program accepts_nested_attributes_for :venue accepts_nested_attributes_for :tickets, allow_destroy: true accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true diff --git a/app/views/conferences/_booths.html.haml b/app/views/conferences/_booths.html.haml index b40af9b8..39dc9253 100644 --- a/app/views/conferences/_booths.html.haml +++ b/app/views/conferences/_booths.html.haml @@ -6,7 +6,7 @@ .row .col-md-12.text-center %h2 Booths - - @conference.booths.confirmed.each_slice(3).with_index do |slice, index_for_row| + - @conference.confirmed_booths.each_slice(3).with_index do |slice, index_for_row| .row.row-centered - slice.each.with_index do |booth, index_for_column| .col-md-4.col-sm-4.col-xs-10.col-centered.col-top @@ -18,7 +18,7 @@ %h3.text-center = booth.title %p.text-center.text-muted - = link_to "#show_descrition_#{index_for_row}_#{index_for_column}", "data-toggle"=>"collapse" do + = link_to "#show_description_#{index_for_row}_#{index_for_column}", "data-toggle"=>"collapse" do learn more - .collapse{ id: "show_descrition_#{index_for_row}_#{index_for_column}" } + .collapse{ id: "show_description_#{index_for_row}_#{index_for_column}" } = markdown(booth.description) diff --git a/app/views/conferences/_call_for_paper.html.haml b/app/views/conferences/_call_for_paper.html.haml index 289c3d9e..2dbd2ecd 100644 --- a/app/views/conferences/_call_for_paper.html.haml +++ b/app/views/conferences/_call_for_paper.html.haml @@ -12,32 +12,34 @@ .row .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 %p - - if @conference.program.event_types.any? + - if @conference.event_types.any? You can submit proposals for %span.notranslate = "#{event_types(@conference)}." - - if @conference.program.tracks.any? + - if @conference.confirmed_tracks.any? Proposals should fit in one of the %span.notranslate - = "#{pluralize(@conference.program.tracks.count, 'track')}:" + = "#{pluralize(@conference.confirmed_tracks.length, 'track')}:" = "#{tracks(@conference)}." - The submission period has begun - %em.notranslate - = @conference.program.cfp.start_date.strftime('%A, %B %-d. %Y') - and closes - %em.notranslate - = @conference.program.cfp.end_date.strftime('%A, %B %-d. %Y.') - - if @conference.program.cfp_open? - That means you have only - %b.notranslate= pluralize(@conference.program.cfp.remaining_days, 'day') - left! + - if @conference.call_for_events.try(:open?) + The submission period is open + %em.notranslate + = "#{date_string(@conference.call_for_events.start_date, + @conference.call_for_events.end_date)}." + %b + You have + = pluralize(@conference.call_for_events.remaining_days, 'day') + left! Remember %span.notranslate - = @conference.short_title - will only be as good as the sessions you present. Submit early, submit often! + = @conference.title + will only be as good as the sessions you present. + Submit early, submit often! - else The submission period is closed. .row .col-md-12.text-center %p.cta-button - = link_to "Submit your paper now", conference_program_proposals_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' + = link_to "Submit your paper now", + conference_program_proposals_path(@conference.short_title), + class: 'btn btn-success btn-lg text-center' diff --git a/app/views/conferences/_call_for_tracks.html.haml b/app/views/conferences/_call_for_tracks.html.haml index 1abeb956..c457880d 100644 --- a/app/views/conferences/_call_for_tracks.html.haml +++ b/app/views/conferences/_call_for_tracks.html.haml @@ -12,19 +12,17 @@ .row .col-md-6.col-md-offset-3.col-sm-10.col-sm-offset-1 %p - The submission period for track requests has begun + The submission period for track requests is open %em.notranslate - = @conference.program.cfps.for_tracks.start_date.strftime('%A, %B %-d. %Y') - and closes - %em.notranslate - = @conference.program.cfps.for_tracks.end_date.strftime('%A, %B %-d. %Y.') - - if @conference.program.cfps.for_tracks.try(:open?) - That means you have only - %b.notranslate= pluralize(@conference.program.cfps.for_tracks.remaining_days, 'day') + = "#{date_string(@conference.call_for_tracks.start_date, + @conference.call_for_tracks.end_date)}." + %b + You have + = pluralize(@conference.call_for_tracks.remaining_days, 'day') left! - - else - The submission period for track requests is closed. .row .col-md-12.text-center %p.cta-button - = link_to "Submit your request for track", conference_program_tracks_path(@conference.short_title), class: 'btn btn-success btn-lg text-center' + = link_to("Submit your request for track", + conference_program_tracks_path(@conference.short_title), + class: 'btn btn-success btn-lg text-center') diff --git a/app/views/conferences/_lodging.html.haml b/app/views/conferences/_lodging.html.haml index 561e2421..a9754190 100644 --- a/app/views/conferences/_lodging.html.haml +++ b/app/views/conferences/_lodging.html.haml @@ -13,9 +13,9 @@ %p.lead We recommend these affordable lodging accommodations for your visit. - .row.row-centered{ style:"display: flex; flex-wrap: wrap" } + .row.row-centered - @conference.lodgings.each do |lodging| - .col-md-4.col-sm-4.col-centered.col-top{ style:"display:flex;" } + .col-md-4.col-sm-4.col-centered.col-top .thumbnail - if lodging.picture? -if lodging.website_link.present? @@ -30,8 +30,8 @@ %i.fa.fa-home.fa-5x - else %i.fa.fa-home.fa-5x - .caption - %h3.text-center - = lodging.name - -if lodging.description.present? - = markdown(lodging.description) + .caption + %h3.text-center + = lodging.name + -if lodging.description.present? + = markdown(lodging.description) diff --git a/app/views/conferences/_schedule_splashpage.html.haml b/app/views/conferences/_schedule_splashpage.html.haml index 790582cb..10584bcb 100644 --- a/app/views/conferences/_schedule_splashpage.html.haml +++ b/app/views/conferences/_schedule_splashpage.html.haml @@ -1,3 +1,8 @@ += content_for :splash_nav do + %li + =link_to('#program', class: 'smoothscroll') do + Program + .container .row .col-md-12 @@ -5,43 +10,41 @@ Program %p.lead.text-center %span.notranslate - = @conference.short_title + = @conference.title has the most awesome program ever! - - if @conference.splashpage and @conference.program.tracks.any? and @conference.splashpage.include_tracks + - if @conference.splashpage.include_tracks && @conference.confirmed_tracks.any? See rock-star speakers cover the topics of - - if @conference.splashpage and @conference.splashpage.include_tracks - - @conference.program.tracks.confirmed.each_slice(3) do |slice| - .row.row-centered - - slice.each do |track| - .col-md-4.col-sm-4.col-centered.col-top.track - %h4.text-center - = track.name - = markdown(track.description) - - if track.start_date - %br - From: #{track.start_date.strftime('%A, %B %-d. %Y')} - - if track.end_date - %br - To: #{track.end_date.strftime('%A, %B %-d. %Y')} - - if track.room - %br - In: #{track.room.name} + - @conference.confirmed_tracks.each_slice(3) do |slice| + .row.row-centered + - slice.each do |track| + .col-md-4.col-sm-4.col-centered.col-top.track + %h4.text-center + = track.name + = markdown(track.description) + - if track.start_date + %br + From: #{track.start_date.strftime('%A, %B %-d. %Y')} + - if track.end_date + %br + To: #{track.end_date.strftime('%A, %B %-d. %Y')} + - if track.room + %br + In: #{track.room.name} - - if @conference.program and @conference.program.schedule_public + - if @conference.program.try(:schedule_public?) .row .col-md-12 %p.cta-button.text-center = link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule - %h3.text-center Don't miss out! %br - - if @conference.program.events.highlights.any? + - if @conference.highlighted_events.any? .row .col-md-12 - - @conference.program.events.highlights.each_slice(2) do |slice| + - @conference.highlighted_events.each_slice(2) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered.col-top.highlights @@ -50,8 +53,3 @@ %h5.text-center = markdown truncate(event.abstract, length: 500, separator: ' ') = link_to "Read More", conference_program_proposal_path(@conference.short_title, event) - - = content_for :splash_nav do - %li - =link_to('#program', class: 'smoothscroll') do - Program diff --git a/app/views/conferences/_sponsors.html.haml b/app/views/conferences/_sponsors.html.haml index aa7921b5..94da9940 100644 --- a/app/views/conferences/_sponsors.html.haml +++ b/app/views/conferences/_sponsors.html.haml @@ -31,7 +31,7 @@ = sponsor.description .modal-footer = link_to nil, "#{sponsor.website_url}", target: '_blank' - -if @conference.contact and !@conference.contact.sponsor_email.blank? + - if @conference.call_for_sponsors.try(:open?) .row .col-md-12 %p.text-muted.text-center diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index dd6b2d62..8fa4bf5f 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -37,7 +37,7 @@ %h3.text-center = markdown(@conference.description) - - if @conference.registration_open? and @conference.splashpage.include_registrations + - if @conference.splashpage.include_registrations && @conference.registration_open? %section#registration = render 'registration' @@ -45,35 +45,35 @@ %section#program = render 'schedule_splashpage' - - if @conference.program.cfp_open? and @conference.splashpage.include_cfp + - if @conference.splashpage.include_cfp && @conference.call_for_events.try(:open?) %section#callforpapers = render 'call_for_paper' - - if @conference.program.cfps.for_tracks.try(:open?) && @conference.splashpage.include_cfp + - if @conference.splashpage.include_cfp && @conference.call_for_tracks.try(:open?) %section#callfortracks = render 'call_for_tracks' - - if @conference.venue and @conference.splashpage.include_venue + - if @conference.splashpage.include_venue && @conference.venue %section#venue = render 'venue' - - if @conference.lodgings.any? and @conference.splashpage.include_lodgings + - if @conference.splashpage.include_lodgings && @conference.lodgings.any? %section#lodging = render 'lodging' - - if @conference.tickets.any? and @conference.splashpage.include_tickets and @conference.pending? + - if @conference.splashpage.include_tickets && @conference.tickets.any? && @conference.pending? %section#tickets = render 'tickets' - - if @conference.booths.confirmed.any? and @conference.splashpage.include_booths + - if @conference.splashpage.include_booths && @conference.confirmed_booths.any? %section#booths = render 'booths' - - if @conference.sponsors.any? and @conference.splashpage.include_sponsors + - if @conference.splashpage.include_sponsors && @conference.sponsors.any? %section#sponsors = render 'sponsors' - - if @conference.contact.has_social_media? and @conference.splashpage.include_social_media + - if @conference.splashpage.include_social_media && @conference.contact.has_social_media? %section#social-media = render 'social_media' diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index 10d4c386..dc645a11 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -7,7 +7,7 @@ = link_to(edit_user_path(current_user.id)) do %span.fa.fa-user Edit Profile --if @conference and @conference.program +-if @conference && @conference.program %li = link_to(conference_program_proposals_path(@conference.short_title)) do %span.fa.fa-comment @@ -16,7 +16,7 @@ = link_to(conference_program_tracks_path(@conference.short_title)) do %span.fa.fa-road My Tracks --if @conference && @conference.program && (@conference.program.cfps.for_booths.try(:open?) || current_user.booths.where(conference_id: @conference.id).count > 0) +-if @conference && (@conference.call_for_booths.try(:open?) || current_user.booths.where(conference_id: @conference.id).count > 0) %li = link_to (conference_booths_path(@conference.short_title)) do %span.fa.fa-shopping-bag @@ -41,7 +41,7 @@ =link_to(new_admin_conference_path) do %span.fa.fa-plus New Conference - -if @conference and @conference.id and can? :show, @conference + -if @conference && @conference.id && can?(:show, @conference) %li = link_to(admin_conference_path(@conference.short_title)) do %span.fa.fa-cog