Merge d425349bdd into eb9d799f23
This commit is contained in:
commit
4a624f10eb
6 changed files with 73 additions and 3 deletions
16
lib/root_route_constraint.rb
Normal file
16
lib/root_route_constraint.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
class RootRouteConstraint
|
||||
def initialize
|
||||
@current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current)
|
||||
@current = Conference.where('start_date = ?', Date.current + 1) if @current.blank?
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if only one conference is live and has a public splashpage
|
||||
# If any conference is live it checks how many live conferences are there
|
||||
# ====Returns
|
||||
# * +true+ -> only one conferene is live AND the conference has public splashpage
|
||||
# * +false+ -> no or more than one conferences are live or the only live conferece has no public splashpage
|
||||
def matches?(*)
|
||||
@current.present? && @current.first.splashpage.present? && @current.count == 1 && @current.first.splashpage.public?
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue