Class: V2Users::RestaurantsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationV2Controller
- BaseController
- V2Users::RestaurantsController
- Includes:
- AdminHelper, ImageHelper, ManageRestaurantsController
- Defined in:
- app/controllers/v2_users/restaurants_controller.rb
Overview
Accessible restaurant data by public
Instance Attribute Summary collapse
-
#restaurant ⇒ Object
readonly
Returns the value of attribute restaurant.
Instance Method Summary collapse
- #menus ⇒ Object
-
#preview_menu_from_email ⇒ Object
it contains imenu pro iframe 'View Menu' button in confirmation email refers to this page.
- #search ⇒ Object
- #show ⇒ Object
Methods included from ImageHelper
Methods included from ManageRestaurantsController
#create, #cuisines, #owner_get_ready, #sign_up_premium, #tag_groups
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 inherited from BaseController
#activate_cache?, #current_user_ck, default_url_options, #identity_cache_memoization, #set_csrf_token
Methods included from LogrageCustomLogger
Methods included from UpdateLocaleConcern
Methods included from ResponseCacheConcern
Methods inherited from ApplicationV2Controller
Instance Attribute Details
#restaurant ⇒ Object (readonly)
Returns the value of attribute restaurant.
11 12 13 |
# File 'app/controllers/v2_users/restaurants_controller.rb', line 11 def restaurant @restaurant end |
Instance Method Details
#menus ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/v2_users/restaurants_controller.rb', line 42 def etag = CityHash.hash32([restaurant.cache_key, params]) my_response_cache("#{self.class}:menus:#{etag}", :html) do ids = if params[:ids].present? params[:ids].respond_to?(:values) ? params[:ids].values : params[:ids] elsif params[:id].present? params[:id].respond_to?(:values) ? params[:id].values : params[:id] elsif params[:package_ids] params[:package_ids].respond_to?(:values) ? params[:package_ids].values : params[:package_ids] else restaurant.restaurant_package_ids end rest_packs = HhPackage::RestaurantPackage.fetch_multi(Array.wrap(ids)) raise ActiveRecord::RecordNotFound if rest_packs.blank? = rest_packs.map do |rest_pack| rest_pack.fetch_package&. end.compact.uniq.last view_name = case .to_s.to_sym when :imenupro @menus = (rest_packs) 'menus_imenupro' when :img @menus = (rest_packs) 'menus_img' when :img_and_imenupro if params.key? :imenupro_only @menus = (rest_packs) 'menus_imenupro' else @imenupro_menus = (rest_packs) @img_menus = (rest_packs) 'menus_img_and_imenupro' end else 'blank_menu' end render_to_string(view_name, layout: nil) end end |
#preview_menu_from_email ⇒ Object
it contains imenu pro iframe 'View Menu' button in confirmation email refers to this page
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/v2_users/restaurants_controller.rb', line 88 def return unless activate_cache? etag: @restaurant.cache_key, last_modified: @restaurant.updated_at if @restaurant.active && @restaurant.any_offers? @menus = @restaurant.restaurant_packages.map(&:fetch_package).map do |package| if package..to_s.to_sym == :imenupro package..map do |link| id = link.split('!').last { id: id, link: link, type: :imenupro } end else package..order_by_rank.map do || { url: .image_url, type: :img } end end end.flatten elsif @restaurant..present? @menu = @restaurant. end end |
#search ⇒ Object
34 35 36 |
# File 'app/controllers/v2_users/restaurants_controller.rb', line 34 def search redirect_to_new_ui("restaurants/search") end |
#show ⇒ Object
38 39 40 |
# File 'app/controllers/v2_users/restaurants_controller.rb', line 38 def show redirect_to_new_ui("restaurants/#{params[:id]}") end |