Enable registration to proceed without requiring a ticket.

Requiring a ticket after registration is convoluted; while it may be neccesary
for some workflows, it definitely isn't for others, and the core of osem
doesn't need it... so let's make it optional.
This commit is contained in:
James Mason 2018-12-29 00:08:32 -08:00 committed by Henne Vogelsang
parent 228190396c
commit 072116fffe
12 changed files with 168 additions and 128 deletions

View file

@ -117,10 +117,7 @@ class AdminAbility
can :manage, Commercial, commercialable_type: 'Conference',
commercialable_id: conf_ids
can :manage, Registration, conference_id: conf_ids
can :manage, RegistrationPeriod do |registration_period|
conference = registration_period.conference
conf_ids.include?(conference.id) && conference.tickets.for_registration.any?
end
can :manage, RegistrationPeriod, conference_id: conf_ids
can :manage, Booth, conference_id: conf_ids
can :manage, Question, conference_id: conf_ids
can :manage, Question do |question|

View file

@ -29,11 +29,7 @@ class Conference < ApplicationRecord
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :supporters, through: :ticket_purchases, source: :user
has_many :tickets, dependent: :destroy do
def for_registration
where(registration_ticket: true)
end
end
has_many :tickets, dependent: :destroy
has_many :resources, dependent: :destroy
has_many :booths, dependent: :destroy
has_many :confirmed_booths, -> { where(state: 'confirmed') }, class_name: 'Booth'

View file

@ -10,6 +10,8 @@ class Ticket < ApplicationRecord
monetize :price_cents, with_model_currency: :price_currency
scope :for_registration, -> { where(registration_ticket: true) }
# This validation is for the sake of simplicity.
# If we would allow different currencies per conference we also have to handle convertions between currencies!
validate :tickets_of_conference_have_same_currency