Remove travel schedule from registration
(cherry picked from commit d18cc02f0185df39bb4213d8a63a955dfb433dcb) Re: https://github.com/openSUSE/osem/issues/2333
This commit is contained in:
parent
ab0ff0ff03
commit
7a04f3582f
16 changed files with 29 additions and 144 deletions
|
|
@ -28,8 +28,6 @@ class Registration < ApplicationRecord
|
|||
|
||||
validates :user_id, uniqueness: { scope: :conference_id, message: 'already Registered!' }
|
||||
validate :registration_limit_not_exceed, on: :create
|
||||
validate :registration_to_events_only_if_present
|
||||
|
||||
validates :accepted_code_of_conduct, acceptance: {
|
||||
if: -> { conference.try(:code_of_conduct).present? }
|
||||
}
|
||||
|
|
@ -48,19 +46,6 @@ class Registration < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
##
|
||||
# If the user registers to attend events that are already scheduled,
|
||||
# only allow registration to events if the user will be present
|
||||
# (based on arrival and departure attributes)
|
||||
# No validation if arrival/departure attributes are empty
|
||||
def registration_to_events_only_if_present
|
||||
if (arrival || departure) && events.pluck(:start_time).any?
|
||||
errors.add(:arrival, 'is too late! You cannot register for events that take place before your arrival') if events.pluck(:start_time).compact.map { |x| x < arrival }.any?
|
||||
|
||||
errors.add(:departure, 'is too early! You cannot register for events that take place after your departure') if events.pluck(:start_time).compact.map { |x| x > departure }.any?
|
||||
end
|
||||
end
|
||||
|
||||
def subscribe_to_conference
|
||||
Subscription.create(conference_id: conference.id, user_id: user.id)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue