develop #3

Merged
kbe merged 227 commits from develop into main 2025-09-16 14:35:23 +00:00
2 changed files with 12 additions and 2 deletions
Showing only changes of commit ee43996a77 - Show all commits

View File

@@ -96,6 +96,12 @@ class Event < ApplicationRecord
Time.current >= end_time Time.current >= end_time
end end
# Check if booking is allowed during the event
# This is a simple attribute reader that defaults to false if nil
def allow_booking_during_event?
!!allow_booking_during_event
end
private private
# Determine if we should perform server-side geocoding # Determine if we should perform server-side geocoding

View File

@@ -1,7 +1,7 @@
class TicketType < ApplicationRecord class TicketType < ApplicationRecord
# Associations # Associations
belongs_to :event belongs_to :event
has_many :tickets, dependent: :destroy has_many :tickets, dependent: :destroy # Cannot delete ticket types if already tickets sold
# Validations # Validations
validates :name, presence: true, length: { minimum: 3, maximum: 50 } validates :name, presence: true, length: { minimum: 3, maximum: 50 }
@@ -80,6 +80,10 @@ class TicketType < ApplicationRecord
def sale_times_within_event_period def sale_times_within_event_period
return unless event&.start_time && sale_end_at return unless event&.start_time && sale_end_at
# Only enforce this restriction if booking during event is not allowed
unless event.allow_booking_during_event?
errors.add(:sale_end_at, "cannot be after the event starts") if sale_end_at > event.start_time errors.add(:sale_end_at, "cannot be after the event starts") if sale_end_at > event.start_time
end end
end end
end