mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Allow confirmed speakers to register anytime
If the registration period is over then speakers of confirmed events can't register anymore. They should be able to, since they are gonna be there anyway. * Allow the speakers of confirmed events to register regardless of the registration period * Provision for registrations of confirmed speakers, so as not to exceed the registration limit * Add scope for registered speakers Fix #829 and fix #802
This commit is contained in:
parent
1c12200003
commit
fdff485b3e
5 changed files with 16 additions and 5 deletions
|
|
@ -80,7 +80,7 @@ class Ability
|
|||
|
||||
can [:new, :create], Registration do |registration|
|
||||
conference = registration.conference
|
||||
conference.registration_open? && !conference.registration_limit_exceeded?
|
||||
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
|
||||
end
|
||||
|
||||
can :index, Ticket
|
||||
|
|
|
|||
|
|
@ -594,8 +594,15 @@ class Conference < ActiveRecord::Base
|
|||
(email_settings.conference_registration_dates_updated_subject.present? && email_settings.conference_registration_dates_updated_body.present?)
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the registration limit has been exceeded
|
||||
# Additionally, it takes into account the confirmed speakers that haven't registered yet
|
||||
#
|
||||
# ====Returns
|
||||
# * +True+ -> If the registration limit has been reached or exceeded
|
||||
# * +False+ -> If the registration limit hasn't been exceeded
|
||||
def registration_limit_exceeded?
|
||||
registration_limit > 0 && registrations.count >= registration_limit
|
||||
registration_limit > 0 && registrations.count + program.speakers.confirmed.count - program.speakers.confirmed.registered(program.conference).count >= registration_limit
|
||||
end
|
||||
|
||||
# Returns an hexadecimal color given a collection. The returned color changed
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ class Program < ActiveRecord::Base
|
|||
def confirmed
|
||||
joins(:events).where(events: { state: :confirmed })
|
||||
end
|
||||
|
||||
def registered(conference)
|
||||
joins(:registrations).where('registrations.conference_id = ?', conference.id)
|
||||
end
|
||||
end
|
||||
|
||||
accepts_nested_attributes_for :event_types, allow_destroy: true
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@
|
|||
= f.input :start_hour, input_html: {size: 2, type: 'number', min: 0, max: 23}
|
||||
= f.input :end_hour, input_html: {size: 2, type: 'number', min: 1, max: 24}
|
||||
= f.inputs name: 'Registrations' do
|
||||
= f.input :registration_limit, as: :number, in: 0..9999, hint: 'Limit the number of registrations to the conference (0 no limit). You currently have ' + pluralize(@conference.registrations.count, 'registration')
|
||||
= f.input :registration_limit, as: :number, in: 0..9999, hint: 'Limit the number of registrations to the conference (0 no limit). Please note that the registration limit doesn\'t apply to speakers of confirmed events (they will still be able to register even if it has been reached). You currently have ' + pluralize(@conference.registrations.count, 'registration')
|
||||
= f.action :submit, as: :button, button_html: {class: 'btn btn-primary'}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
- if conference.user_registered?(current_user)
|
||||
= link_to "My Registration", conference_conference_registration_path(conference.short_title), class: 'btn btn-default'
|
||||
- else
|
||||
= link_to "Register", new_conference_conference_registration_path(conference.short_title), class: "btn btn-default", disabled: conference.registration_limit_exceeded?
|
||||
- if conference.registration_limit_exceeded?
|
||||
= link_to "Register", new_conference_conference_registration_path(conference.short_title), class: "btn btn-default", disabled: cannot?(:new, Registration.new(conference_id: conference.id))
|
||||
- if cannot?(:new, Registration.new(conference_id: conference.id)) && conference.registration_limit_exceeded?
|
||||
Sorry, no places left
|
||||
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
||||
= link_to "My Proposals", conference_program_proposals_path(conference.short_title), class: 'btn btn-default'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue