diff --git a/app/models/conference.rb b/app/models/conference.rb index 7f821cdc..9adac888 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -719,7 +719,7 @@ class Conference < ApplicationRecord # * +True+ -> If the registration limit has been reached or exceeded # * +False+ -> If the registration limit hasn't been exceeded def registration_limit_exceeded? - registration_limit > 0 && registrations.count + program.speakers.confirmed.count - program.speakers.confirmed.registered(program.conference).count >= registration_limit + registration_limit > 0 && registrations.count + program.speakers.confirmed.unregistered(program.conference).count >= registration_limit end # Returns an hexadecimal color given a collection. The returned color changed diff --git a/app/models/program.rb b/app/models/program.rb index dab2f2b6..14554786 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -51,6 +51,10 @@ class Program < ApplicationRecord def registered(conference) joins(:registrations).where('registrations.conference_id = ?', conference.id) end + + def unregistered(conference) + self - registered(conference) + end end accepts_nested_attributes_for :event_types, allow_destroy: true