This commit is contained in:
Arun Kumar 2017-02-18 13:02:20 +00:00 committed by GitHub
commit b946b9f261
2 changed files with 16 additions and 3 deletions

View file

@ -14,7 +14,7 @@ class ConferenceRegistrationsController < ApplicationController
return
# ichain does not allow us to create users during registration
elsif (ENV['OSEM_ICHAIN_ENABLED'] == 'true') && !current_user
redirect_to root_path, alert: 'You need to sign in or sign up before continuing.'
redirect_to new_user_ichain_session_path, alert: 'You need to sign in or sign up before continuing.'
return
end

View file

@ -45,14 +45,20 @@ class Ability
# can view Commercials of confirmed Events
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
can [:show, :create], User
unless ENV['OSEM_ICHAIN_ENABLED'] == 'true'
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
can [:new, :create], Registration do |registration|
conference = registration.conference
can_register?(conference, registration)
end
else
can :show, Registration do |registration|
registration.new_record?
end
can [:new, :create], Registration do |registration|
conference = registration.conference
conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded?
can_register?(conference, registration)
end
can :show, Event do |event|
@ -62,6 +68,7 @@ class Ability
can [:new, :create], Event do |event|
event.program.cfp_open? && event.new_record?
end
end
end
@ -262,3 +269,9 @@ class Ability
end
end
end
def can_register? conference, registration
conference.registration_open? &&
registration.new_record? &&
!conference.registration_limit_exceeded?
end