This commit is contained in:
Siddhant Bajaj 2017-06-07 11:00:29 +00:00 committed by GitHub
commit cc7e17bf4a

View file

@ -27,6 +27,7 @@ class Registration < ActiveRecord::Base
validates :user_id, uniqueness: { scope: :conference_id, message: 'already Registered!' }
validate :registration_limit_not_exceed, on: :create
validate :registration_to_events_only_if_present
validate :before_end_of_registration_period, on: :create
after_create :set_week, :subscribe_to_conference, :send_registration_mail
@ -59,6 +60,12 @@ class Registration < ActiveRecord::Base
end
end
def before_end_of_registration_period
if conference && conference.registration_period && conference.registration_period.end_date && (Date.today > conference.registration_period.end_date)
errors.add(:created_at, "can't be after the registration period end date!")
end
end
def subscribe_to_conference
Subscription.create(conference_id: conference.id, user_id: user.id)
end