This commit is contained in:
Toks
2014-03-06 21:47:30 -05:00
28 changed files with 385 additions and 74 deletions

View File

@@ -624,7 +624,7 @@ class Post < ActiveRecord::Base
module FavoriteMethods
def clean_fav_string?
rand(100) < [Math.log(fav_string.size, 2), 5].min
rand(100) < 50
end
def clean_fav_string!

View File

@@ -242,8 +242,8 @@ class User < ActiveRecord::Base
end
end
def promote_to(level)
update_attributes({:level => level}, :as => :admin)
def promote_to!(new_level)
UserPromotion.new(self, CurrentUser.user, new_level).promote!
end
def promote_to_admin_if_first_user
@@ -281,6 +281,10 @@ class User < ActiveRecord::Base
end
end
def level_string_was
level_string(level_was)
end
def level_string(value = nil)
case (value || level)
when Levels::BLOCKED
@@ -357,7 +361,7 @@ class User < ActiveRecord::Base
def create_mod_action
if level_changed?
ModAction.create(:description => %{"#{name}":/users/#{id} level changed #{level_string(level_was)} -> #{level_string}})
ModAction.create(:description => %{"#{name}":/users/#{id} level changed #{level_string_was} -> #{level_string}})
end
end

View File

@@ -3,7 +3,8 @@ class UserFeedback < ActiveRecord::Base
belongs_to :user
belongs_to :creator, :class_name => "User"
before_validation :initialize_creator, :on => :create
attr_accessible :body, :user_id, :category, :user_name
attr_accessor :disable_dmail_notification
attr_accessible :body, :user_id, :category, :user_name, :disable_dmail_notification
validates_presence_of :user, :creator, :body, :category
validates_inclusion_of :category, :in => %w(positive negative neutral)
validate :creator_is_gold
@@ -74,8 +75,10 @@ class UserFeedback < ActiveRecord::Base
end
def create_dmail
body = %{#{creator_name} created a "#{category} record":/user_feedbacks?search[user_id]=#{user_id} for your account. #{body}}
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
unless disable_dmail_notification
body = %{#{creator_name} created a "#{category} record":/user_feedbacks?search[user_id]=#{user_id} for your account. #{body}}
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
end
end
def creator_is_gold