1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

fix create event without custom price + fix test fixtures

This commit is contained in:
Sylvain 2016-08-30 14:48:22 +02:00
parent 4f41aa6554
commit ea73b9a88b
2 changed files with 9 additions and 7 deletions

View File

@ -88,9 +88,11 @@ class API::EventsController < API::ApiController
# convert main price to centimes
event_preparams.merge!(amount: (event_preparams[:amount].to_i * 100 if event_preparams[:amount].present?))
# delete non-complete "other" prices and convert them to centimes
event_preparams[:event_price_categories_attributes].delete_if { |price_cat| price_cat[:price_category_id].empty? or price_cat[:amount].empty? }
event_preparams[:event_price_categories_attributes].each do |price_cat|
price_cat[:amount] = price_cat[:amount].to_i * 100
unless event_preparams[:event_price_categories_attributes].nil?
event_preparams[:event_price_categories_attributes].delete_if { |price_cat| price_cat[:price_category_id].empty? or price_cat[:amount].empty? }
event_preparams[:event_price_categories_attributes].each do |price_cat|
price_cat[:amount] = price_cat[:amount].to_i * 100
end
end
# return the resulting params object
event_preparams

View File

@ -1,9 +1,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
description: MyText
name: "- de 25 ans"
conditions: "Tarif réservé aux jeunes de moins de 25 ans"
two:
name: MyString
description: MyText
name: "chômeurs"
conditions: "Tarif préférentiel pour les demandeurs d'emploi pouvant justifier de leur situation."