osem-fcy/app/controllers/conferences_controller.rb

108 lines
2.8 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class ConferencesController < ApplicationController
protect_from_forgery with: :null_session
before_action :respond_to_options
2022-05-18 17:46:37 -03:00
before_action :conference, only: [:show]
before_action :set_conferences_service, only: [:show]
load_and_authorize_resource find_by: :short_title, except: :show
2014-08-12 11:51:59 +03:00
2014-11-14 17:24:24 +01:00
def index
@current = Conference.upcoming.reorder(start_date: :asc)
@antiquated = Conference.past
if @antiquated.empty? && @current.empty? && User.empty?
render :new_install
end
2014-11-14 17:24:24 +01:00
end
def show
authorize! :show, @conference # TODO: reduce the 10 queries performed here
splashpage = @conference.splashpage
unless splashpage.present?
2018-01-16 19:38:22 -06:00
redirect_to admin_conference_splashpage_path(@conference.short_title) && return
end
2022-05-18 17:46:37 -03:00
handle_present_splash_page(splashpage)
end
2014-06-30 19:24:26 +05:30
2021-02-14 22:56:45 +01:00
def calendar
respond_to do |format|
format.ics do
calendar = Icalendar::Calendar.new
Conference.all.each do |conf|
2022-05-18 17:46:37 -03:00
service = ConferenceCalendarService.new(calendar, conf)
calendar = if params[:full]
service.full_calendar
else
service.not_full_calendar
end
2021-02-14 22:56:45 +01:00
end
calendar.publish
render inline: calendar.to_ical
end
end
end
2014-11-14 17:24:24 +01:00
private
2022-05-18 17:46:37 -03:00
def handle_present_splash_page(splashpage)
@image_url = @service.conference_image_url(request)
if splashpage.include_cfp
cfp_variables
end
if splashpage.include_program
program_variables
end
@tickets = @service.if_include_registrations_or_tickets
@lodgings = @service.if_include_lodgings
if splashpage.include_sponsors
sponsor_variables
end
end
def program_variables
@highlights = @conference.highlighted_events.eager_load(:speakers)
@tracks = @service.if_include_tracks
@booths = @service.if_include_booths
end
def cfp_variables
@call_for_events = @service.cfp_call_by_type('events')
@event_types, @track_names = @service.cfp_variables_if_event_open(@call_for_events)
@call_for_tracks = @service.cfp_call_by_type('tracks')
@call_for_booths = @service.cfp_call_by_type('booths')
end
def sponsor_variables
@sponsorship_levels = @service.sponsorship_levels
@sponsors = @conference.sponsors
end
def conference
@conference = ConferencesService.conference_by_filter(conference_finder_conditions)
end
def set_conferences_service
@service = ConferencesService.new(@conference)
end
def conference_finder_conditions
if params[:id]
{ short_title: params[:id] }
else
{ custom_domain: request.domain }
end
end
2015-10-28 18:05:15 +02:00
def respond_to_options
respond_to do |format|
format.html { head :ok }
end if request.options?
end
end