1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/controllers/api/pricing_controller.rb

33 lines
906 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-12-01 15:43:16 +01:00
# @deprecated
# <b>DEPRECATED:</b> Please use <tt>API::PriceController</tt> instead.
# API Controller for managing Plans prices
2023-02-24 17:26:55 +01:00
class API::PricingController < API::APIController
2022-12-01 15:43:16 +01:00
include ApplicationHelper
before_action :authenticate_user!, except: %i[index update]
2016-03-23 18:39:41 +01:00
def index
@group_pricing = Group.includes(:plans, :trainings_pricings)
end
def update
authorize :pricing, :update?
if params[:training].present?
training = Training.find params[:training]
params[:group_pricing].each do |group_id, amount|
next unless training
group = Group.includes(:plans).find(group_id)
next unless group
training_pricing = group.trainings_pricings.find_or_initialize_by(training_id: training.id)
2022-12-01 15:43:16 +01:00
training_pricing.amount = to_centimes(amount)
training_pricing.save
2016-03-23 18:39:41 +01:00
end
end
2022-12-01 15:43:16 +01:00
head :ok
2016-03-23 18:39:41 +01:00
end
end