Merge 0b435e6567 into 08e5f10559
This commit is contained in:
commit
cc7e17bf4a
1 changed files with 7 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ class Registration < ActiveRecord::Base
|
||||||
validates :user_id, uniqueness: { scope: :conference_id, message: 'already Registered!' }
|
validates :user_id, uniqueness: { scope: :conference_id, message: 'already Registered!' }
|
||||||
validate :registration_limit_not_exceed, on: :create
|
validate :registration_limit_not_exceed, on: :create
|
||||||
validate :registration_to_events_only_if_present
|
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
|
after_create :set_week, :subscribe_to_conference, :send_registration_mail
|
||||||
|
|
||||||
|
|
@ -59,6 +60,12 @@ class Registration < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
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
|
def subscribe_to_conference
|
||||||
Subscription.create(conference_id: conference.id, user_id: user.id)
|
Subscription.create(conference_id: conference.id, user_id: user.id)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue