Assert that a user has a paid ticket before registering for a conference.

This commit is contained in:
Michael Ball 2020-07-11 00:57:08 -07:00
parent 69b18a97e1
commit 5bef4b7004
2 changed files with 18 additions and 0 deletions

View file

@ -30,6 +30,7 @@ class Conference < ApplicationRecord
has_many :payments, dependent: :destroy
has_many :supporters, through: :ticket_purchases, source: :user
has_many :tickets, dependent: :destroy
has_many :registration_tickets, -> { for_registration }, class_name: 'Ticket'
has_many :resources, dependent: :destroy
has_many :booths, dependent: :destroy
has_many :confirmed_booths, -> { where(state: 'confirmed') }, class_name: 'Booth'
@ -111,6 +112,13 @@ class Conference < ApplicationRecord
user.present? && registrations.where(user_id: user.id).count > 0
end
##
# True when there is at least one ticket marked as "registration"
# A user must get a registration ticket before registering.
def registration_ticket_required?
tickets.for_registration.any?
end
##
# Delete all EventSchedules that are not in the hours range
# After the conference has been successfully updated