User#grant_moderatorship_by_user!
This commit is contained in:
parent
e0b7c25758
commit
c3b62cc166
|
@ -24,7 +24,7 @@ class Hat < ActiveRecord::Base
|
||||||
h = "<span class=\"hat\" title=\"Granted by " <<
|
h = "<span class=\"hat\" title=\"Granted by " <<
|
||||||
"#{self.granted_by_user.username} on " <<
|
"#{self.granted_by_user.username} on " <<
|
||||||
"#{self.created_at.strftime("%Y-%m-%d")}"
|
"#{self.created_at.strftime("%Y-%m-%d")}"
|
||||||
|
|
||||||
if !hl && self.link.present?
|
if !hl && self.link.present?
|
||||||
h << " - #{self.link}"
|
h << " - #{self.link}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -209,6 +209,27 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def grant_moderatorship_by_user!(user)
|
||||||
|
User.transaction do
|
||||||
|
self.is_moderator = true
|
||||||
|
self.save!
|
||||||
|
|
||||||
|
m = Moderation.new
|
||||||
|
m.moderator_user_id = user.id
|
||||||
|
m.user_id = self.id
|
||||||
|
m.action = "Granted moderator status"
|
||||||
|
m.save!
|
||||||
|
|
||||||
|
h = Hat.new
|
||||||
|
h.user_id = self.id
|
||||||
|
h.granted_by_user_id = user.id
|
||||||
|
h.hat = "Sysop"
|
||||||
|
h.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def initiate_password_reset_for_ip(ip)
|
def initiate_password_reset_for_ip(ip)
|
||||||
self.password_reset_token = "#{Time.now.to_i}-#{Utils.random_str(30)}"
|
self.password_reset_token = "#{Time.now.to_i}-#{Utils.random_str(30)}"
|
||||||
self.save!
|
self.save!
|
||||||
|
|
Loading…
Reference in a new issue