Class: Cats::Core::RoundPlansController
Instance Method Summary
collapse
Methods included from Common
#create, #show, #update
#authenticate, #current_user, #skip_bullet
Instance Method Details
#approve ⇒ Object
20
21
22
23
24
25
|
# File 'app/controllers/cats/core/round_plans_controller.rb', line 20
def approve
plan = @service.approve(params[:id])
render json: {success: true, data: serialize(plan)}
rescue StandardError => e
render json: {success: false, error: e.message}, status: :unprocessable_entity
end
|
#filter ⇒ Object
15
16
17
18
|
# File 'app/controllers/cats/core/round_plans_controller.rb', line 15
def filter
query = RoundPlan.includes({plan: :program}, :region).ransack(params[:q])
render json: {success: true, data: serialize(query.result)}
end
|
#generate ⇒ Object
27
28
29
30
31
|
# File 'app/controllers/cats/core/round_plans_controller.rb', line 27
def generate
p = model_params
plan = @service.generate_round_plan(p[:reference_no], p[:rounds], p[:plan_id], p[:region_id])
render json: {success: true, data: serialize(plan)}
end
|
#generate_round_needs ⇒ Object
33
34
35
36
37
38
|
# File 'app/controllers/cats/core/round_plans_controller.rb', line 33
def generate_round_needs
plan = @service.generate_round_needs(params[:id])
render json: {success: true, data: serialize(plan)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|
#index ⇒ Object
9
10
11
12
13
|
# File 'app/controllers/cats/core/round_plans_controller.rb', line 9
def index
super do
RoundPlan.includes({plan: :program}, :region).where(plan: params[:id])
end
end
|
#remove_items ⇒ Object
40
41
42
43
44
45
|
# File 'app/controllers/cats/core/round_plans_controller.rb', line 40
def remove_items
plan = @service.remove_items(params[:id], remove_params[:ids])
render json: {success: true, data: serialize(plan)}
rescue StandardError => e
render json: {success: false, error: e.message}
end
|