mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #989 from Ana06/registration_limit
registration_limit check moved to ability file
This commit is contained in:
commit
c39a4541cf
2 changed files with 5 additions and 8 deletions
|
|
@ -6,7 +6,7 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
|
||||
def new
|
||||
@registration = Registration.new(conference_id: @conference.id)
|
||||
authorize! :new, @registration
|
||||
authorize! :new, @registration, message: "Sorry, you can not register for #{@conference.title}. Registration limit exceeded or the registration is not open."
|
||||
|
||||
# Redirect to registration edit when user is already registered
|
||||
if @conference.user_registered?(current_user)
|
||||
|
|
@ -23,11 +23,6 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
redirect_to edit_conference_conference_registrations_path(@conference.short_title)
|
||||
end
|
||||
|
||||
if @conference.registration_limit_exceeded?
|
||||
redirect_to root_path, error: "Sorry, registration limit exceeded for #{@conference.title}"
|
||||
return
|
||||
end
|
||||
|
||||
# @user variable needs to be set so that _sign_up_form_embedded works properly
|
||||
@user = @registration.build_user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ class Ability
|
|||
end
|
||||
|
||||
can [:new, :create], Registration do |registration|
|
||||
registration.conference.registration_open? && registration.new_record?
|
||||
conference = registration.conference
|
||||
conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded?
|
||||
end
|
||||
|
||||
can :show, Event do |event|
|
||||
|
|
@ -74,7 +75,8 @@ class Ability
|
|||
can :manage, Registration, user_id: user.id
|
||||
|
||||
can [:new, :create], Registration do |registration|
|
||||
registration.conference.registration_open?
|
||||
conference = registration.conference
|
||||
conference.registration_open? && !conference.registration_limit_exceeded?
|
||||
end
|
||||
|
||||
can :index, Ticket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue