posts: remove rating, note, and status locks.

Remove the ability for users to lock ratings, note, and post statuses.

Historically the majority of locked posts were from 10+ years ago when
certain users habitually locked ratings and notes on every post they
touched for no reason. Nowadays most posts have been unlocked. Only a
handful of locked posts are left, none of which deserve to be locked.

The is_rating_locked, is_note_locked, and is_status_locked columns still
exist in the database, but aren't used.
This commit is contained in:
evazion
2021-09-27 21:56:41 -05:00
parent 3e4492ce33
commit 126046cb69
13 changed files with 39 additions and 447 deletions

View File

@@ -35,8 +35,6 @@ class ModAction < ApplicationRecord
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

@@ -13,7 +13,6 @@ class Note < ApplicationRecord
validate :note_within_image
after_save :update_post
after_save :create_version
validate :validate_post_is_not_locked
scope :active, -> { where(is_active: true) }
@@ -28,10 +27,6 @@ class Note < ApplicationRecord
extend SearchMethods
def validate_post_is_not_locked
errors.add(:post, "is note locked") if post.is_note_locked?
end
def note_within_image
return false unless post.present?
if x < 0 || y < 0 || (x > post.image_width) || (y > post.image_height) || width < 0 || height < 0 || (x + width > post.image_width) || (y + height > post.image_height)

View File

@@ -27,11 +27,9 @@ class Post < ApplicationRecord
validate :has_copyright_tag
validate :has_enough_tags
validate :post_is_not_its_own_parent
validate :updater_can_change_rating
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
@@ -255,7 +253,7 @@ class Post < ApplicationRecord
end
def is_approvable?(user = CurrentUser.user)
!is_status_locked? && !is_active? && uploader != user
!is_active? && uploader != user
end
def flag!(reason, is_deletion: false)
@@ -533,7 +531,7 @@ class Post < ApplicationRecord
end
def filter_metatags(tags)
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|-?locked):/i}
@pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent):/i}
tags = apply_categorization_metatags(tags)
@post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav|-fav|child|-child|-favgroup|favgroup|upvote|downvote|status|-status|disapproved):/i}
apply_pre_metatags
@@ -653,15 +651,6 @@ class Post < ApplicationRecord
when /^rating:([qse])/i
self.rating = $1
when /^(-?)locked:notes?$/i
self.is_note_locked = ($1 != "-") if CurrentUser.is_builder?
when /^(-?)locked:rating$/i
self.is_rating_locked = ($1 != "-") if CurrentUser.is_builder?
when /^(-?)locked:status$/i
self.is_status_locked = ($1 != "-") if CurrentUser.is_admin?
end
end
end
@@ -912,11 +901,6 @@ class Post < ApplicationRecord
module DeletionMethods
def expunge!
if is_status_locked?
errors.add(:is_status_locked, "; cannot delete post")
return false
end
transaction do
Post.without_timeout do
ModAction.log("permanently deleted post ##{id} (md5=#{md5})", :post_permanent_delete)
@@ -1257,12 +1241,11 @@ class Post < ApplicationRecord
:id, :created_at, :updated_at, :rating, :source, :pixiv_id, :fav_count,
:score, :up_score, :down_score, :md5, :file_ext, :file_size, :image_width,
:image_height, :tag_count, :has_children, :has_active_children,
:is_note_locked, :is_rating_locked, :is_status_locked, :is_pending,
:is_flagged, :is_deleted, :is_banned, :last_comment_bumped_at,
:last_commented_at, :last_noted_at, :uploader_ip_addr,
:uploader, :approver, :parent, :upload, :artist_commentary,
:flags, :appeals, :notes, :comments, :children, :approvals,
:replacements, :pixiv_ugoira_frame_data
:is_pending, :is_flagged, :is_deleted, :is_banned,
:last_comment_bumped_at, :last_commented_at, :last_noted_at,
:uploader_ip_addr, :uploader, :approver, :parent, :upload,
:artist_commentary, :flags, :appeals, :notes, :comments, :children,
:approvals, :replacements, :pixiv_ugoira_frame_data
)
if params[:tags].present?
@@ -1354,13 +1337,6 @@ class Post < ApplicationRecord
end
end
def updater_can_change_rating
# Don't forbid changes if the rating lock was just now set in the same update.
if rating_changed? && is_rating_locked? && !is_rating_locked_changed?
errors.add(:rating, "is locked and cannot be changed. Unlock the post first.")
end
end
def uploader_is_not_limited
errors.add(:uploader, "have reached your upload limit") if uploader.upload_limit.limited?
end
@@ -1487,32 +1463,6 @@ 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_create)
else
ModAction.log("unlocked notes for post ##{id}", :post_note_lock_delete)
end
end
if is_rating_locked != is_rating_locked_was
if is_rating_locked
ModAction.log("locked rating for post ##{id}", :post_rating_lock_create)
else
ModAction.log("unlocked rating for post ##{id}", :post_rating_lock_delete)
end
end
if is_status_locked != is_status_locked_was
if is_status_locked
ModAction.log("locked status for post ##{id}", :post_status_lock_create)
else
ModAction.log("unlocked status for post ##{id}", :post_status_lock_delete)
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

View File

@@ -31,7 +31,7 @@ class PostAppeal < ApplicationRecord
end
def validate_post_is_appealable
errors.add(:post, "cannot be appealed") if post.is_status_locked? || !post.is_appealable?
errors.add(:post, "cannot be appealed") if !post.is_appealable?
end
def self.available_includes

View File

@@ -8,10 +8,6 @@ class PostApproval < ApplicationRecord
def validate_approval
post.lock!
if post.is_status_locked?
errors.add(:post, "is locked and cannot be approved")
end
if post.is_active?
errors.add(:post, "is already active and cannot be approved")
end

View File

@@ -99,7 +99,6 @@ class PostFlag < ApplicationRecord
def validate_post
errors.add(:post, "is pending and cannot be flagged") if post.is_pending? && !is_deletion
errors.add(:post, "is deleted and cannot be flagged") if post.is_deleted? && !is_deletion
errors.add(:post, "is locked and cannot be flagged") if post.is_status_locked?
flag = post.flags.in_cooldown.last
if !is_deletion && flag.present?