Refactored condition to check if splashpage is present.

This commit is contained in:
Marie-Elise 2018-01-15 22:23:38 -06:00 committed by James Mason
parent 34af9b840b
commit afff7e1c66

View file

@ -20,41 +20,42 @@ class ConferencesController < ApplicationController
authorize! :show, @conference # TODO: reduce the 10 queries performed here authorize! :show, @conference # TODO: reduce the 10 queries performed here
splashpage = @conference.splashpage splashpage = @conference.splashpage
if !splashpage.present?
redirect_to admin_conference_splashpage_path(@conference.short_title) unless splashpage.present?
else redirect_to admin_conference_splashpage_path(@conference.short_title) and return
if splashpage.include_cfp end
cfps = @conference.program.cfps
@call_for_events = cfps.find { |call| call.cfp_type == 'events' } if splashpage.include_cfp
if @call_for_events.try(:open?) cfps = @conference.program.cfps
@event_types = @conference.event_types.pluck(:title) @call_for_events = cfps.find { |call| call.cfp_type == 'events' }
@track_names = @conference.confirmed_tracks.pluck(:name).sort if @call_for_events.try(:open?)
end @event_types = @conference.event_types.pluck(:title)
@call_for_tracks = cfps.find { |call| call.cfp_type == 'tracks' } @track_names = @conference.confirmed_tracks.pluck(:name).sort
end end
if splashpage.include_program @call_for_tracks = cfps.find { |call| call.cfp_type == 'tracks' }
@highlights = @conference.highlighted_events.eager_load(:speakers) end
if splashpage.include_tracks if splashpage.include_program
@tracks = @conference.confirmed_tracks.eager_load( @highlights = @conference.highlighted_events.eager_load(:speakers)
:room if splashpage.include_tracks
).order('tracks.name') @tracks = @conference.confirmed_tracks.eager_load(
end :room
if splashpage.include_booths ).order('tracks.name')
@booths = @conference.confirmed_booths.order('title')
end
end end
if splashpage.include_registrations || splashpage.include_tickets if splashpage.include_booths
@tickets = @conference.tickets.order('price_cents') @booths = @conference.confirmed_booths.order('title')
end
if splashpage.include_lodgings
@lodgings = @conference.lodgings.order('name')
end
if splashpage.include_sponsors
@sponsorship_levels = @conference.sponsorship_levels.eager_load(
:sponsors
).order('sponsorship_levels.position ASC', 'sponsors.name')
end end
end end
if splashpage.include_registrations || splashpage.include_tickets
@tickets = @conference.tickets.order('price_cents')
end
if splashpage.include_lodgings
@lodgings = @conference.lodgings.order('name')
end
if splashpage.include_sponsors
@sponsorship_levels = @conference.sponsorship_levels.eager_load(
:sponsors
).order('sponsorship_levels.position ASC', 'sponsors.name')
end
end end
private private