add additional mod actions
This commit is contained in:
@@ -7,6 +7,8 @@ class BulkRevert
|
|||||||
def self.process(constraints)
|
def self.process(constraints)
|
||||||
obj = BulkRevert.new(constraints)
|
obj = BulkRevert.new(constraints)
|
||||||
|
|
||||||
|
ModAction.log("#{CurrentUser.name} processed bulk revert for #{constraints.inspect}")
|
||||||
|
|
||||||
obj.find_post_versions.order("updated_at, id").each do |version|
|
obj.find_post_versions.order("updated_at, id").each do |version|
|
||||||
version.undo!
|
version.undo!
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,13 @@ class Comment < ActiveRecord::Base
|
|||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
before_validation :initialize_updater
|
before_validation :initialize_updater
|
||||||
after_create :update_last_commented_at_on_create
|
after_create :update_last_commented_at_on_create
|
||||||
|
after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do
|
||||||
|
ModAction.log("comment ##{rec.id} updated by #{CurrentUser.name}")
|
||||||
|
end
|
||||||
after_destroy :update_last_commented_at_on_destroy
|
after_destroy :update_last_commented_at_on_destroy
|
||||||
|
after_destroy(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do
|
||||||
|
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}")
|
||||||
|
end
|
||||||
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin]
|
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin]
|
||||||
attr_accessible :is_sticky, :as => [:moderator, :admin]
|
attr_accessible :is_sticky, :as => [:moderator, :admin]
|
||||||
mentionable(
|
mentionable(
|
||||||
@@ -19,7 +25,7 @@ class Comment < ActiveRecord::Base
|
|||||||
:user_field => :creator_id,
|
:user_field => :creator_id,
|
||||||
:title => "You were mentioned in a comment",
|
:title => "You were mentioned in a comment",
|
||||||
:body => lambda {|rec, user_name| "You were mentioned in a \"comment\":/posts/#{rec.post_id}#comment-#{rec.id}\n\n---\n\n[i]#{rec.creator.name} said:[/i]\n\n#{ActionController::Base.helpers.excerpt(rec.body, user_name)}"}
|
:body => lambda {|rec, user_name| "You were mentioned in a \"comment\":/posts/#{rec.post_id}#comment-#{rec.id}\n\n---\n\n[i]#{rec.creator.name} said:[/i]\n\n#{ActionController::Base.helpers.excerpt(rec.body, user_name)}"}
|
||||||
)
|
)
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def recent
|
def recent
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ class ForumPost < ActiveRecord::Base
|
|||||||
validate :topic_is_not_restricted, :on => :create
|
validate :topic_is_not_restricted, :on => :create
|
||||||
before_destroy :validate_topic_is_unlocked
|
before_destroy :validate_topic_is_unlocked
|
||||||
after_save :delete_topic_if_original_post
|
after_save :delete_topic_if_original_post
|
||||||
|
after_update(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
|
||||||
|
ModAction.log("#{CurrentUser.name} updated forum post ##{rec.id}")
|
||||||
|
end
|
||||||
|
after_destroy(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
|
||||||
|
ModAction.log("#{CurrentUser.name} deleted forum post ##{rec.id}")
|
||||||
|
end
|
||||||
mentionable(
|
mentionable(
|
||||||
:message_field => :body,
|
:message_field => :body,
|
||||||
:user_field => :creator_id,
|
:user_field => :creator_id,
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ class IpBan < ActiveRecord::Base
|
|||||||
validates_format_of :ip_addr, :with => IP_ADDR_REGEX
|
validates_format_of :ip_addr, :with => IP_ADDR_REGEX
|
||||||
validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX}
|
validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX}
|
||||||
attr_accessible :ip_addr, :reason
|
attr_accessible :ip_addr, :reason
|
||||||
|
after_create do
|
||||||
|
ModAction.log("#{CurrentUser.name} created ip ban for #{rec.ip_addr}")
|
||||||
|
end
|
||||||
|
after_destroy do
|
||||||
|
ModAction.log("#{CurrentUser.name} deleted ip ban for ##{rec.ip_addr}")
|
||||||
|
end
|
||||||
|
|
||||||
def self.is_banned?(ip_addr)
|
def self.is_banned?(ip_addr)
|
||||||
exists?(["ip_addr = ?", ip_addr])
|
exists?(["ip_addr = ?", ip_addr])
|
||||||
@@ -31,7 +37,7 @@ class IpBan < ActiveRecord::Base
|
|||||||
return {
|
return {
|
||||||
"comments" => comments,
|
"comments" => comments,
|
||||||
"notes" => notes,
|
"notes" => notes,
|
||||||
"pools" => pools,
|
# "pools" => pools,
|
||||||
"wiki_pages" => wiki_pages
|
"wiki_pages" => wiki_pages
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
validate :creator_is_gold
|
validate :creator_is_gold
|
||||||
validate :user_is_not_creator
|
validate :user_is_not_creator
|
||||||
after_create :create_dmail
|
after_create :create_dmail
|
||||||
|
after_update(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
|
||||||
|
ModAction.log("#{CurrentUser.name} updated user feedback for #{rec.user_name}")
|
||||||
|
end
|
||||||
|
after_destroy(:if => lambda {|rec| rec.updater_id != rec.creator_id}) do
|
||||||
|
ModAction.log("#{CurrentUser.name} deleted user feedback for #{rec.user_name}")
|
||||||
|
end
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def positive
|
def positive
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ FactoryGirl.define do
|
|||||||
bit_prefs User.flag_value_for("can_upload_free")
|
bit_prefs User.flag_value_for("can_upload_free")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory(:contrib_user) do
|
||||||
|
level 32
|
||||||
|
bit_prefs User.flag_value_for("can_upload_free")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
factory(:janitor_user) do
|
factory(:janitor_user) do
|
||||||
level 35
|
level 35
|
||||||
can_approve_posts true
|
can_approve_posts true
|
||||||
@@ -48,6 +54,11 @@ FactoryGirl.define do
|
|||||||
can_approve_posts true
|
can_approve_posts true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory(:mod_user) do
|
||||||
|
level 40
|
||||||
|
can_approve_posts true
|
||||||
|
end
|
||||||
|
|
||||||
factory(:admin_user) do
|
factory(:admin_user) do
|
||||||
level 50
|
level 50
|
||||||
can_approve_posts true
|
can_approve_posts true
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
context "that mentions a user" do
|
context "that mentions a user" do
|
||||||
setup do
|
setup do
|
||||||
@post = FactoryGirl.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@@ -206,6 +205,21 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
assert_equal(c1.id, matches.all[1].id)
|
assert_equal(c1.id, matches.all[1].id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "that is edited by a moderator" do
|
||||||
|
setup do
|
||||||
|
@post = FactoryGirl.create(:post)
|
||||||
|
@comment = FactoryGirl.create(:comment, :post_id => @post.id)
|
||||||
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
|
CurrentUser.user = @mod
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a mod action" do
|
||||||
|
assert_difference("ModAction.count") do
|
||||||
|
@comment.update_attributes({:body => "nope"}, :as => :moderator)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "that is below the score threshold" do
|
context "that is below the score threshold" do
|
||||||
should "be hidden if not stickied" do
|
should "be hidden if not stickied" do
|
||||||
user = FactoryGirl.create(:user, :comment_threshold => 0)
|
user = FactoryGirl.create(:user, :comment_threshold => 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user