mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
refactored DomainConstraint and conference_controller_spec
use params id instead of OSEM_HOSTNAME to load conference
This commit is contained in:
parent
66b48be968
commit
835859e350
3 changed files with 18 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
|||
class ConferencesController < ApplicationController
|
||||
protect_from_forgery with: :null_session
|
||||
before_action :respond_to_options
|
||||
load_and_authorize_resource find_by: :short_title
|
||||
load_and_authorize_resource find_by: :short_title, except: :show
|
||||
|
||||
def index
|
||||
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
|
||||
|
|
@ -9,15 +9,19 @@ class ConferencesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
# have to change "localhost" to ENV['OSEM_HOSTNAME'] in production
|
||||
check_custom_domain if request.host != 'localhost'
|
||||
@conference = if params[:id]
|
||||
Conference.find_by_short_title(params[:id])
|
||||
else
|
||||
load_conference_by_domain
|
||||
end
|
||||
authorize! :show, @conference
|
||||
@program = @conference.program
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_custom_domain
|
||||
@conference = @conference.nil? ? Conference.find_by(custom_domain: request.domain) : @conference
|
||||
def load_conference_by_domain
|
||||
Conference.find_by(custom_domain: request.domain)
|
||||
end
|
||||
|
||||
def respond_to_options
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue