Add unregistered speakers scope to program
And use it in Conference#registration_limit_exceeded? Also change self.registered(conference) to registered(conference) to fix failures in linters
This commit is contained in:
parent
e5948698db
commit
979377f2df
2 changed files with 5 additions and 1 deletions
|
|
@ -719,7 +719,7 @@ class Conference < ApplicationRecord
|
||||||
# * +True+ -> If the registration limit has been reached or exceeded
|
# * +True+ -> If the registration limit has been reached or exceeded
|
||||||
# * +False+ -> If the registration limit hasn't been exceeded
|
# * +False+ -> If the registration limit hasn't been exceeded
|
||||||
def registration_limit_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
|
end
|
||||||
|
|
||||||
# Returns an hexadecimal color given a collection. The returned color changed
|
# Returns an hexadecimal color given a collection. The returned color changed
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@ class Program < ApplicationRecord
|
||||||
def registered(conference)
|
def registered(conference)
|
||||||
joins(:registrations).where('registrations.conference_id = ?', conference.id)
|
joins(:registrations).where('registrations.conference_id = ?', conference.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unregistered(conference)
|
||||||
|
self - registered(conference)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
accepts_nested_attributes_for :event_types, allow_destroy: true
|
accepts_nested_attributes_for :event_types, allow_destroy: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue