FEATURE: Allow sending invites to staged users

This commit is contained in:
Gerhard Schlager
2018-01-19 15:29:15 +01:00
parent f74ac826c5
commit dde0fcc658
7 changed files with 79 additions and 20 deletions

View File

@ -218,6 +218,7 @@ class User < ActiveRecord::Base
end
EMAIL = %r{([^@]+)@([^\.]+)}
FROM_STAGED = "from_staged".freeze
def self.new_from_params(params)
user = User.new
@ -228,6 +229,16 @@ class User < ActiveRecord::Base
user
end
def self.unstage(params)
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
params.each { |k, v| user.send("#{k}=", v) }
user.staged = false
user.active = false
user.custom_fields[FROM_STAGED] = true
end
user
end
def self.suggest_name(email)
return "" if email.blank?
email[/\A[^@]+/].tr(".", " ").titleize
@ -987,6 +998,10 @@ class User < ActiveRecord::Base
self.user_stat&.time_read
end
def from_staged?
custom_fields[User::FROM_STAGED]
end
protected
def badge_grant