diff --git a/app/models/ability.rb b/app/models/ability.rb index 06e4b611..955ee8a0 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 - can_register?(conference) + can_register?(conference, registration) end can :show, Event do |event| @@ -63,11 +69,6 @@ class Ability event.program.cfp_open? && event.new_record? end - else - can [:new, :create], Registration do |registration| - conference = registration.conference - can_register?(conference) - end end end @@ -244,7 +245,7 @@ class Ability end end -def can_register? conference +def can_register? conference, registration conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded?