Add booth limit

This commit is contained in:
nasia 2017-07-28 21:46:48 +03:00 committed by nasia-sam
parent 703813248d
commit e73218b5ca
10 changed files with 66 additions and 18 deletions

View file

@ -25,6 +25,7 @@ class Booth < ActiveRecord::Base
:submitter_relationship,
presence: true
scope :accepted, -> { where(state: 'accepted') }
scope :confirmed, -> { where(state: 'confirmed') }
mount_uploader :picture, PictureUploader, mount_on: :logo_link

View file

@ -738,6 +738,15 @@ class Conference < ActiveRecord::Base
(start_hour..(end_hour - 1)).cover?(current_hour) ? current_hour - start_hour : 0
end
##
#
# ====Returns
# * +True+ -> if accepted booths are equal to the booth limit
# * +False+ -> Accepted booths have not reached the booth limit
def maximum_accepted_booths?
booth_limit > 0 && booths.accepted.count + booths.confirmed.count >= booth_limit
end
##
# Return the current conference object to be used in RevisionCount
#