Class: FestivityEventsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Festivity::Mixins::NotFound
Defined in:
app/controllers/festivity_events_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/festivity_events_controller.rb', line 9

def index
  order_by = params[:sort] ? params[:sort] : "start_date"
  @title = "#{current_site.festivity_festival_name}: Events"
  @filter_type = current_site.festivity_filter_type
  @events =  Rails.cache.fetch("#{cache_key}", expires_in: 2.hours) do
    FestivityEventList.search(
        {dates: search_dates.join(","),
         categories: params[:categories],
        filter_type: current_site.festivity_filter_type},
        order_by).events
  end


  @selected_dates = params[:dates] ? FestivityDatetimeFilterPresenter.parse(params[:dates].split(","), current_site.festivity_filter_type) : []
  @selected_categories = params[:categories] ? params[:categories].split(",") : []
  @selected_sort = order_by
  # If the request is AJAX, only return the event list itself, not the full page
  if request.xhr?
    render partial: "event_list"
  else
    render 'index'
  end

end

#showObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/festivity_events_controller.rb', line 34

def show
  @event = FestivityEventPage.find_by_slug_and_status_id(params[:id], Status[:published].id)
  if @event
    @page = @event
    @related_events = FestivityEventList.find_related_events(
        {dates: search_dates.join(","), event_id: @event.id,
         categories: @event.festivity_categories.map{|cat| cat.id}}).events
    @title = "#{current_site.festivity_festival_name}: #{@event.title}"
  else
    file_not_found_for_site
  end

end