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

Merge branch '2-0-rc1'

This commit is contained in:
cyril 2016-04-20 11:48:19 +02:00
commit bbe4cebbf5
3 changed files with 13 additions and 12 deletions

View File

@ -13,8 +13,7 @@ class Event < ActiveRecord::Base
attr_accessor :recurrence, :recurrence_end_at attr_accessor :recurrence, :recurrence_end_at
after_create :event_recurrence after_create :event_recurrence
before_save :set_nb_free_places before_save :update_nb_free_places
before_update :update_nb_free_places, if: :nb_total_places_changed?
def name def name
title title
@ -33,6 +32,10 @@ class Event < ActiveRecord::Base
end end
end end
def reservations
Reservation.where(reservable: self)
end
private private
def event_recurrence def event_recurrence
if recurrence.present? and recurrence != 'none' if recurrence.present? and recurrence != 'none'
@ -79,14 +82,12 @@ class Event < ActiveRecord::Base
end end
end end
def set_nb_free_places def update_nb_free_places
if nb_free_places.nil? if nb_total_places.nil?
self.nb_free_places = nb_total_places self.nb_free_places = nil
else
reserved_places = reservations.map{|r| r.nb_reserve_places + r.nb_reserve_reduced_places}.inject(0){|sum, t| sum + t }
self.nb_free_places = (nb_total_places - reserved_places)
end end
end end
def update_nb_free_places
diff = nb_total_places - nb_total_places_was
self.nb_free_places += diff
end
end end

View File

@ -106,7 +106,7 @@ en:
trainings: trainings:
# training availabilities # training availabilities
i_ve_reserved: "I've reserved" i_ve_reserved: "I've reserved"
completed: "Completed" completed: "Full"
export_members: export_members:
# members list export to EXCEL format # members list export to EXCEL format

View File

@ -106,7 +106,7 @@ fr:
trainings: trainings:
# disponibilités formations # disponibilités formations
i_ve_reserved: "J'ai réservé" i_ve_reserved: "J'ai réservé"
completed: "Effectué" completed: "Complet"
export_members: export_members:
# export de la liste des members au format EXCEL # export de la liste des members au format EXCEL