Fixed registration emails and modified the schedule

This commit is contained in:
Godwin
2016-09-21 21:37:16 -07:00
parent 2fe8b3c93d
commit 0770fd28e8
7 changed files with 77 additions and 32 deletions
+44
View File
@@ -28,4 +28,48 @@ class ConferenceRegistration < ActiveRecord::Base
def self.all_considerations
[:vegan, :smoking, :pets, :quiet]
end
def status(was = false)
return :unregistered if user.firstname.blank? || self.send(was ? :city_was : :city).blank?
return :registered if self.send(was ? :housing_was : :housing).present? || (self.send(was ? :can_provide_housing_was : :can_provide_housing) && (self.send(was ? :housing_data_was : :housing_data) || {})['availability'].present?)
return :preregistered
end
around_update :check_status
def check_status
yield #saves
old_status = status(true)
new_status = status
puts " ===== #{old_status.to_s} : #{new_status.to_s} ==> #{conference.registration_status} ===== "
if old_status.present? && old_status != new_status
if (conference.registration_status == :pre && new_status == :preregistered) ||
(conference.registration_status == :open && new_status == :registered)
UserMailer.send_mail :registration_confirmation do
{
:args => self
}
end
end
end
end
# before_update do | registration |
# old_status = status
# new_status = registration.status
# puts " ===== #{old_status.to_s} : #{new_status.to_s} ===== "
# if old_status.present? && old_status != new_status
# if (conference.registration_status == :pre && new_status == :preregistered) ||
# (conference.registration_status == :open && new_status == :registered)
# end
# UserMailer.send_mail :registration_confirmation do
# {
# :args => registration
# }
# end
# end
# end
end
+4
View File
@@ -12,6 +12,10 @@ class User < ActiveRecord::Base
has_many :authentications, :dependent => :destroy
accepts_nested_attributes_for :authentications
before_update do |user|
user.locale ||= I18n.locale
end
before_save do |user|
user.locale ||= I18n.locale
end