1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/controllers/api/trainings_pricings_controller.rb
2022-12-01 15:43:16 +01:00

34 lines
915 B
Ruby

# frozen_string_literal: true
# @deprecated
# <b>DEPRECATED:</b> Please use <tt>API::PriceController</tt> instead.
# API Controller for managing Training prices
class API::TrainingsPricingsController < API::ApiController
include ApplicationHelper
before_action :authenticate_user!
def index
@trainings_pricings = TrainingsPricing.all
end
def update
if current_user.admin?
@trainings_pricing = TrainingsPricing.find(params[:id])
trainings_pricing_parameters = trainings_pricing_params
trainings_pricing_parameters[:amount] = to_centimes(trainings_pricing_parameters[:amount])
if @trainings_pricing.update(trainings_pricing_parameters)
render status: :ok
else
render status: :unprocessable_entity
end
else
head :forbidden
end
end
def trainings_pricing_params
params.require(:trainings_pricing).permit(:amount)
end
end