hide approval mod actions, better logic for user promotion/demotion mod actions
This commit is contained in:
@@ -10,6 +10,10 @@ class ModAction < ActiveRecord::Base
|
|||||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:all].blank?
|
||||||
|
q = q.where("description not like ")
|
||||||
|
end
|
||||||
|
|
||||||
q
|
q
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class Post < ActiveRecord::Base
|
|||||||
self.is_deleted = false
|
self.is_deleted = false
|
||||||
self.approver_id = CurrentUser.id
|
self.approver_id = CurrentUser.id
|
||||||
save!
|
save!
|
||||||
ModAction.create(:description => "approved post ##{id}")
|
# ModAction.create(:description => "approved post ##{id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def disapproved_by?(user)
|
def disapproved_by?(user)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class User < ActiveRecord::Base
|
|||||||
has_many :note_versions, :foreign_key => "updater_id"
|
has_many :note_versions, :foreign_key => "updater_id"
|
||||||
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
has_many :dmails, :foreign_key => "owner_id", :order => "dmails.id desc"
|
||||||
belongs_to :inviter, :class_name => "User"
|
belongs_to :inviter, :class_name => "User"
|
||||||
|
after_update :create_mod_action
|
||||||
|
|
||||||
module BanMethods
|
module BanMethods
|
||||||
def validate_ip_addr_is_not_banned
|
def validate_ip_addr_is_not_banned
|
||||||
@@ -61,7 +62,6 @@ class User < ActiveRecord::Base
|
|||||||
module InvitationMethods
|
module InvitationMethods
|
||||||
def invite!(level)
|
def invite!(level)
|
||||||
if level.to_i <= Levels::CONTRIBUTOR
|
if level.to_i <= Levels::CONTRIBUTOR
|
||||||
ModAction.create(:description => "invited user ##{id} (#{name})")
|
|
||||||
self.level = level
|
self.level = level
|
||||||
self.inviter_id = CurrentUser.id
|
self.inviter_id = CurrentUser.id
|
||||||
save
|
save
|
||||||
@@ -254,8 +254,8 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def level_string
|
def level_string(value = nil)
|
||||||
case level
|
case (value || level)
|
||||||
when Levels::BLOCKED
|
when Levels::BLOCKED
|
||||||
"Banned"
|
"Banned"
|
||||||
|
|
||||||
@@ -324,6 +324,12 @@ class User < ActiveRecord::Base
|
|||||||
def is_admin?
|
def is_admin?
|
||||||
level >= Levels::ADMIN
|
level >= Levels::ADMIN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_mod_action
|
||||||
|
if level_changed?
|
||||||
|
ModAction.create(:description => "level changed #{level_string(level_was)} -> #{level_string} by #{CurrentUser.name}")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module EmailMethods
|
module EmailMethods
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ every 1.day do
|
|||||||
runner "Upload.delete_all(['created_at < ?', 1.day.ago])"
|
runner "Upload.delete_all(['created_at < ?', 1.day.ago])"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
every 1.day do
|
||||||
|
runner "ModAction.delete_all(['created_at < ?', 3.days.ago])"
|
||||||
|
end
|
||||||
|
|
||||||
if environment == "production"
|
if environment == "production"
|
||||||
every 1.hour do
|
every 1.hour do
|
||||||
runner "AmazonBackup.execute"
|
runner "AmazonBackup.execute"
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
@user.reload
|
@user.reload
|
||||||
assert_equal(User::Levels::MEMBER, @user.level)
|
assert_equal(User::Levels::MEMBER, @user.level)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "create a mod action" do
|
||||||
|
assert_difference("ModAction.count") do
|
||||||
|
@user.invite!(User::Levels::CONTRIBUTOR)
|
||||||
|
end
|
||||||
|
assert_equal("level changed Member -> Contributor by #{CurrentUser.name}", ModAction.first.description)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "who has negeative feedback and is trying to change their name" do
|
context "who has negeative feedback and is trying to change their name" do
|
||||||
|
|||||||
Reference in New Issue
Block a user