add post lock entries to mod actions

This commit is contained in:
Lily
2021-07-27 07:41:26 -03:00
parent b4dc7487ee
commit 9fb8093052
2 changed files with 33 additions and 0 deletions

View File

@@ -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,

View File

@@ -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