Class: Admin::FooterBannersController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/footer_banners_controller.rb

Overview

typed: ignore frozen_string_literal: true

Constant Summary

Constants inherited from BaseController

BaseController::INTERNAL_SERVER_ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseController

#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Methods included from UpdateLocaleConcern

#setup_locale

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#assign_channelsObject



49
50
51
52
53
54
55
# File 'app/controllers/admin/footer_banners_controller.rb', line 49

def assign_channels
  if Channel.assign_footer_ad ad_channel_params
    redirect_back fallback_location: back_fallback_location, notice: "#{t('activerecord.model.channel_ad.name')} updated"
  else
    redirect_back fallback_location: back_fallback_location, notice: "#{t('activerecord.model.channel_ad.name')} error"
  end
end

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/footer_banners_controller.rb', line 19

def create
  @channel_ad = ChannelAd.new(ad_params)

  if @channel_ad.save
    redirect_to admin_footer_banners_path, notice: "#{t('activerecord.model.channel_ad.name')} created."
  else
    render action: 'new'
  end
end

#destroyObject



37
38
39
40
41
# File 'app/controllers/admin/footer_banners_controller.rb', line 37

def destroy
  @channel_ad.destroy

  redirect_to admin_footer_banners_path, notice: "#{t('activerecord.model.channel_ad.name')} removed."
end

#editObject



17
# File 'app/controllers/admin/footer_banners_controller.rb', line 17

def edit; end

#indexObject



5
6
7
8
9
10
11
# File 'app/controllers/admin/footer_banners_controller.rb', line 5

def index
  @grid = AdminFooterBannersGrid.new(params[:admin_banners_grid]) do |scope|
    scope.page(params[:page])
  end
  etag = CityHash.hash32([self.class.to_s, @grid.assets.cache_key])
  return unless stale?(etag: etag)
end

#newObject



13
14
15
# File 'app/controllers/admin/footer_banners_controller.rb', line 13

def new
  @channel_ad = ChannelAd.new
end

#updateObject



29
30
31
32
33
34
35
# File 'app/controllers/admin/footer_banners_controller.rb', line 29

def update
  if @channel_ad.update_attributes(ad_params)
    redirect_to admin_footer_banners_path, notice: "#{t('activerecord.model.channel_ad.name')} updated."
  else
    render action: 'edit'
  end
end

#view_channelsObject



43
44
45
46
47
# File 'app/controllers/admin/footer_banners_controller.rb', line 43

def view_channels
  @channels = Channel.sort_channel_id.tagged_with(Channel::EXTERNAL_BOOKING)
  @channel_ads = ChannelAd.all
  @footer_banner_ad_manager = ChannelAdManager.includes(:channel_ad).where(ad_type: :footer_banner)
end