mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
0cd841da33
TODO: - events controller - availabilies controller - members controller - plans controller
30 lines
787 B
Ruby
30 lines
787 B
Ruby
# frozen_string_literal: true
|
|
|
|
# API Controller for managing Training prices
|
|
class API::TrainingsPricingsController < API::ApiController
|
|
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] = trainings_pricing_parameters[:amount] * 100
|
|
if @trainings_pricing.update(trainings_pricing_parameters)
|
|
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
|