2019-01-16 16:28:25 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-12-01 15:43:16 +01:00
|
|
|
# @deprecated
|
|
|
|
# <b>DEPRECATED:</b> Please use <tt>API::PriceController</tt> instead.
|
2019-01-16 16:28:25 +01:00
|
|
|
# API Controller for managing Training prices
|
2016-03-23 18:39:41 +01:00
|
|
|
class API::TrainingsPricingsController < API::ApiController
|
2022-12-01 15:43:16 +01:00
|
|
|
include ApplicationHelper
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
|
|
def index
|
2016-06-21 16:04:44 +02:00
|
|
|
@trainings_pricings = TrainingsPricing.all
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2019-01-14 12:57:31 +01:00
|
|
|
if current_user.admin?
|
2016-03-23 18:39:41 +01:00
|
|
|
@trainings_pricing = TrainingsPricing.find(params[:id])
|
2019-01-16 16:28:25 +01:00
|
|
|
trainings_pricing_parameters = trainings_pricing_params
|
2022-12-01 15:43:16 +01:00
|
|
|
trainings_pricing_parameters[:amount] = to_centimes(trainings_pricing_parameters[:amount])
|
2019-01-16 16:28:25 +01:00
|
|
|
if @trainings_pricing.update(trainings_pricing_parameters)
|
2016-03-23 18:39:41 +01:00
|
|
|
render status: :ok
|
|
|
|
else
|
|
|
|
render status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
else
|
2022-12-01 15:43:16 +01:00
|
|
|
head :forbidden
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def trainings_pricing_params
|
|
|
|
params.require(:trainings_pricing).permit(:amount)
|
|
|
|
end
|
|
|
|
end
|