From 9fb80930521a56fc943ed08fdad461816609e389 Mon Sep 17 00:00:00 2001 From: Lily Date: Tue, 27 Jul 2021 07:41:26 -0300 Subject: [PATCH] add post lock entries to mod actions --- app/models/mod_action.rb | 6 ++++++ app/models/post.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index 1796b0c97..8d0c21607 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -31,6 +31,12 @@ class ModAction < ApplicationRecord post_move_favorites: 47, post_regenerate: 48, post_regenerate_iqdb: 49, + post_note_lock_create: 210, + post_note_lock_delete: 212, + post_rating_lock_create: 220, + post_rating_lock_delete: 222, + post_status_lock_create: 230, + post_status_lock_delete: 232, pool_delete: 62, pool_undelete: 63, artist_ban: 184, diff --git a/app/models/post.rb b/app/models/post.rb index 5dde03746..ed88a4990 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -31,6 +31,7 @@ class Post < ApplicationRecord validate :uploader_is_not_limited, on: :create before_save :update_tag_post_counts before_save :set_tag_counts + before_save :create_mod_action_for_lock_change before_create :autoban after_save :create_version after_save :update_parent_on_save @@ -1492,6 +1493,32 @@ class Post < ApplicationRecord save end + def create_mod_action_for_lock_change + if is_note_locked != is_note_locked_was + if is_note_locked + ModAction.log("locked notes for post ##{id}", :post_note_lock) + else + ModAction.log("unlocked notes for post ##{id}", :post_note_unlock) + end + end + + if is_rating_locked != is_rating_locked_was + if is_rating_locked + ModAction.log("locked rating for post ##{id}", :post_rating_lock) + else + ModAction.log("unlocked rating for post ##{id}", :post_rating_unlock) + end + end + + if is_status_locked != is_status_locked_was + if is_status_locked + ModAction.log("locked status for post ##{id}", :post_status_lock) + else + ModAction.log("unlocked status for post ##{id}", :post_status_unlock) + end + end + end + def self.model_restriction(table) super.where(table[:is_pending].eq(false)).where(table[:is_flagged].eq(false)).where(table[:is_deleted].eq(false)) end