From 85f04a826a0ebf9b97733b5628d8c3a14ad7b54a Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Sat, 13 Jan 2018 20:40:16 -0800 Subject: [PATCH] Added additional mod actions --- app/controllers/forum_topics_controller.rb | 2 ++ app/models/artist.rb | 2 ++ app/models/forum_topic.rb | 11 +++++++++++ app/models/mod_action.rb | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 70c2c55d8..0329363ac 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -67,6 +67,7 @@ class ForumTopicsController < ApplicationController def destroy check_privilege(@forum_topic) @forum_topic.delete! + @forum_topic.create_mod_action_for_delete flash[:notice] = "Topic deleted" respond_with(@forum_topic) end @@ -74,6 +75,7 @@ class ForumTopicsController < ApplicationController def undelete check_privilege(@forum_topic) @forum_topic.undelete! + @forum_topic.create_mod_action_for_undelete flash[:notice] = "Topic undeleted" respond_with(@forum_topic) end diff --git a/app/models/artist.rb b/app/models/artist.rb index 919059aeb..b689efd69 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -436,6 +436,7 @@ class Artist < ApplicationRecord end update_column(:is_banned, false) + ModAction.log("unbanned artist ##{id}",:artist_unban) end end end @@ -458,6 +459,7 @@ class Artist < ApplicationRecord end update_column(:is_banned, true) + ModAction.log("banned artist ##{id}",:artist_ban) end end end diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index 061714589..6e1e27aff 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -28,6 +28,9 @@ class ForumTopic < ApplicationRecord validates :title, :length => {:maximum => 255} accepts_nested_attributes_for :original_post after_update :update_orignal_post + after_save(:if => lambda {|rec| rec.is_locked? && rec.is_locked_changed?}) do |rec| + ModAction.log("locked forum topic ##{id} (title: #{title})",:forum_topic_lock) + end module CategoryMethods extend ActiveSupport::Concern @@ -154,6 +157,14 @@ class ForumTopic < ApplicationRecord user.level >= min_level end + def create_mod_action_for_delete + ModAction.log("deleted forum topic ##{id} (title: #{title})",:forum_topic_delete) + end + + def create_mod_action_for_undelete + ModAction.log("undeleted forum topic ##{id} (title: #{title})",:forum_topic_undelete) + end + def initialize_is_deleted self.is_deleted = false if is_deleted.nil? end diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index b76d896d8..656a2ddc2 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -31,8 +31,13 @@ class ModAction < ApplicationRecord post_permanent_delete: 46, pool_delete: 62, pool_undelete: 63, + artist_ban: 184, + artist_unban: 185, comment_update: 81, comment_delete: 82, + forum_topic_delete: 202, + forum_topic_undelete: 203, + forum_topic_lock: 206, forum_post_update: 101, forum_post_delete: 102, tag_alias_create: 120,