Class: Admin::AdaptivePointsController
Constant Summary
BaseController::INTERNAL_SERVER_ERROR_MESSAGE
Instance Method Summary
collapse
#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session
#append_info_to_payload
#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?
#setup_locale
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#create ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 30
def create
@adaptive_point = AdaptivePointsRatio.new(adaptive_points_ratio_params)
if @adaptive_point.save
data = AdaptivePointsSerializer.new(@adaptive_point)
render json: { success: true, message: 'AdaptivePointsRatio successfully created.', data: data.as_json }
else
render action: 'index'
format.json { render json: @adaptive_point.errors, status: :unprocessable_entity }
end
end
|
#destroy ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 53
def destroy
if @adaptive_point.destroy
render json: { success: true }
else
render json: @adaptive_point.errors.full_messages.to_sentence,
status: :unprocessable_entity
end
end
|
#duplicate ⇒ Object
62
63
64
65
66
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 62
def duplicate
@adaptive_point.dup.save!
data = AdaptivePointsSerializer.new(@adaptive_point)
render json: { success: true, message: 'AdaptivePointsRatio successfully created duplicate.', data: data.as_json }
end
|
#edit ⇒ Object
41
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 41
def edit; end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 5
def index
respond_to do |format|
format.html do
set_meta_tags title: 'Adaptive Points List'
end
format.json do
adaptivepoints = AdaptivePointsRatio.all
return unless stale_etag? adaptivepoints, template: false
render json: adaptivepoints,
meta: {
total_adaptive_point: AdaptivePointsRatio.count,
},
each_serializer: AdaptivePointsSerializer,
adapter: :json
end
end
end
|
#new ⇒ Object
26
27
28
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 26
def new
@adaptive_point = AdaptivePointsRatio.new
end
|
#search ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 68
def search
query_params = params.fetch(:adaptive_point, {}).permit(
:id, :campaign_name, :is_active, :start_date, :end_date, :created_at,
:campaign_type, :campaign_id, :resto_group_tag
)
adaptivepoints = AdaptivePointsRatio.all
filter_data = AdaptivePointFilter.new(adaptivepoints, query_params)
@adaptive_points = filter_data.filter
render json: @adaptive_points.order("is_active DESC, COALESCE(end_date, '9999-12-31') ASC"),
meta: {
total_adaptive_point: @adaptive_points.count,
},
each_serializer: AdaptivePointsSerializer,
adapter: :json
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/admin/adaptive_points_controller.rb', line 43
def update
if @adaptive_point.update(adaptive_points_ratio_params)
data = AdaptivePointsSerializer.new(@adaptive_point)
render json: { success: true, message: 'AdaptivePointsRatio successfully updated.', data: data.as_json }
else
render action: 'index'
format.json { render json: @adaptive_point.errors, status: :unprocessable_entity }
end
end
|