Solved Issue 1259
This commit is contained in:
parent
42741fa90b
commit
529b8eb710
4 changed files with 21 additions and 3 deletions
|
|
@ -2,7 +2,7 @@ class ConferencesController < ApplicationController
|
|||
protect_from_forgery with: :null_session
|
||||
before_action :respond_to_options
|
||||
load_and_authorize_resource find_by: :short_title
|
||||
load_resource :program, through: :conference, singleton: true, except: :index
|
||||
load_resource :program, through: :conference, singleton: true, except: [:index, :current]
|
||||
|
||||
def index
|
||||
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
|
||||
|
|
@ -11,6 +11,11 @@ class ConferencesController < ApplicationController
|
|||
|
||||
def show; end
|
||||
|
||||
def current
|
||||
current = Conference.first
|
||||
redirect_to conference_path(current.short_title)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def respond_to_options
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class Ability
|
|||
|
||||
# Abilities for not signed in users (guests)
|
||||
def not_signed_in
|
||||
can [:index], Conference
|
||||
can [:index, :current], Conference
|
||||
can [:show], Conference do |conference|
|
||||
conference.splashpage && conference.splashpage.public == true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
require "root_route_constraint"
|
||||
Osem::Application.routes.draw do
|
||||
|
||||
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
|
|
@ -147,6 +148,8 @@ Osem::Application.routes.draw do
|
|||
end
|
||||
|
||||
get '/admin' => redirect('/admin/conferences')
|
||||
|
||||
constraints RootRouteConstraint.new do
|
||||
get '/' => 'conferences#current'
|
||||
end
|
||||
root to: 'conferences#index', via: [:get, :options]
|
||||
end
|
||||
|
|
|
|||
10
lib/root_route_constraint.rb
Normal file
10
lib/root_route_constraint.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class RootRouteConstraint
|
||||
def initialize
|
||||
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
|
||||
end
|
||||
|
||||
def matches?(*)
|
||||
return unless @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