Redirect home to conference#show if only one conference live tommorow
This commit is contained in:
parent
ee7684d845
commit
d425349bdd
3 changed files with 4 additions and 7 deletions
|
|
@ -13,6 +13,7 @@ class ConferencesController < ApplicationController
|
|||
|
||||
def current
|
||||
current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current).first
|
||||
current = Conference.where('start_date = ?', Date.current + 1).first if current.blank?
|
||||
redirect_to conference_path(current.short_title)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
class RootRouteConstraint
|
||||
def initialize
|
||||
@current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current).reorder(start_date: :asc)
|
||||
@current = Conference.where('start_date <= ? AND end_date >= ?', Date.current, Date.current)
|
||||
@current = Conference.where('start_date = ?', Date.current + 1) if @current.blank?
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -10,10 +11,6 @@ class RootRouteConstraint
|
|||
# * +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?(*)
|
||||
if @current.present? && @current.first.splashpage.present?
|
||||
@current.count == 1 && @current.first.splashpage.public?
|
||||
else
|
||||
false
|
||||
end
|
||||
@current.present? && @current.first.splashpage.present? && @current.count == 1 && @current.first.splashpage.public?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,6 +34,5 @@ describe RootRouteConstraint do
|
|||
constraint = RootRouteConstraint.new
|
||||
expect(constraint.matches?).to eq false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue