Browse Source

Fixed registration status

development
Godwin 8 years ago
parent
commit
3d00b70087
  1. 19
      app/models/conference_registration.rb

19
app/models/conference_registration.rb

@ -34,10 +34,16 @@ class ConferenceRegistration < ActiveRecord::Base
end end
def status(was = false) def status(was = false)
return :unregistered if user.nil? # our user hasn't registered if their user doesn't exist or they haven't entered a city
steps = ((was ? steps_completed_was : steps_completed) || []).map(&:to_sym) return :unregistered if user.nil? || check(:city, was).blank?
return :registered if steps.include?(:hosting) || steps.include?(:questions)
return :preregistered if steps.include?(:contact_info) # registration completes once a guest has entered a housing preference or
# a housing provider has opted in or out of providing housing
return :preregistered unless
check(:housing, was).present? || !check(:can_provide_housing, was).nil?
# they must be registered
return :registered
end end
around_update :check_status around_update :check_status
@ -60,4 +66,9 @@ class ConferenceRegistration < ActiveRecord::Base
end end
end end
end end
private
def check(field, was)
send("#{field}#{was ? '_was' : ''}")
end
end end

Loading…
Cancel
Save