2016-03-23 18:39:41 +01:00
|
|
|
class API::TrainingsPricingsController < API::ApiController
|
|
|
|
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
|
|
|
|
if current_user.is_admin?
|
|
|
|
@trainings_pricing = TrainingsPricing.find(params[:id])
|
|
|
|
_trainings_pricing_params = trainings_pricing_params
|
|
|
|
_trainings_pricing_params[:amount] = _trainings_pricing_params[:amount] * 100
|
|
|
|
if @trainings_pricing.update(_trainings_pricing_params)
|
|
|
|
render status: :ok
|
|
|
|
else
|
|
|
|
render status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
else
|
|
|
|
head 403
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def trainings_pricing_params
|
|
|
|
params.require(:trainings_pricing).permit(:amount)
|
|
|
|
end
|
|
|
|
end
|