mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
Merge branch 'dev' for release 2.5.5
This commit is contained in:
commit
23c0a4db46
@ -1 +1 @@
|
||||
2.5.4
|
||||
2.5.5
|
||||
|
@ -1,5 +1,11 @@
|
||||
# Changelog Fab Manager
|
||||
|
||||
## v2.5.5 2017 May 15
|
||||
|
||||
- Fix a bug: New groups does not have their spaces prices initialized
|
||||
- Fix a bug: Unable to delete a group when its space prices are set
|
||||
- [TODO DEPLOY] `rake fablab:fix:new_group_space_prices` only if module 'Spaces' is/was enabled
|
||||
|
||||
## v2.5.4 2017 May 4
|
||||
|
||||
- Fix a bug: Unable to define application locale other than `fr` or `en`.
|
||||
|
@ -3,6 +3,7 @@ class Group < ActiveRecord::Base
|
||||
has_many :users
|
||||
has_many :trainings_pricings, dependent: :destroy
|
||||
has_many :machines_prices, ->{ where(priceable_type: 'Machine') }, class_name: 'Price', dependent: :destroy
|
||||
has_many :spaces_prices, ->{ where(priceable_type: 'Space') }, class_name: 'Price', dependent: :destroy
|
||||
|
||||
extend FriendlyId
|
||||
friendly_id :name, use: :slugged
|
||||
@ -21,6 +22,7 @@ class Group < ActiveRecord::Base
|
||||
def create_prices
|
||||
create_trainings_pricings
|
||||
create_machines_prices
|
||||
create_spaces_prices
|
||||
end
|
||||
|
||||
def create_trainings_pricings
|
||||
@ -35,6 +37,12 @@ class Group < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def create_spaces_prices
|
||||
Space.all.each do |space|
|
||||
Price.create(priceable: space, group: self, amount: 0)
|
||||
end
|
||||
end
|
||||
|
||||
def create_statistic_subtype
|
||||
user_index = StatisticIndex.find_by(es_type_key: 'user')
|
||||
StatisticSubType.create!({statistic_types: user_index.statistic_types, key: self.slug, label: self.name})
|
||||
|
@ -35,5 +35,17 @@ namespace :fablab do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task new_group_space_prices: :environment do
|
||||
Space.all.each do |space|
|
||||
Group.all.each do |group|
|
||||
begin
|
||||
Price.find(priceable: space, group: group)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Price.create(priceable: space, group: group, amount: 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user