Class: FestivityMarketsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Concerns::FestivityCustomPage, Concerns::FestivitySearchCaching
Defined in:
app/controllers/festivity_markets_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/festivity_markets_controller.rb', line 5

def index

  order_by = params[:sort] ? params[:sort] : "start_date"
  @title = "#{current_site.festivity_festival_name}: Artist's Market"
  @filter_type = current_site.festivity_filter_type
  @markets =  Rails.cache.fetch("#{cache_key}", expires_in: 2.hours) do
    FestivityMarketList.search(
      {dates: search_dates.join(","),
       categories: params[:categories],
       filter_type: current_site.festivity_filter_type}, order_by
    ).markets
  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 market list itself, not the full page
  if request.xhr?
    render partial: "market_list"
  else
    render 'index'
  end

end

#showObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/festivity_markets_controller.rb', line 31

def show
  @market = FestivityMarketPage.find_by_slug_and_status_id(params[:id], Status[:published].id)
  if @market
    @page = @market
    @title = "#{current_site.festivity_festival_name}: #{@market.title}"
  else
    file_not_found_for_site
  end

end