tags: remove tag category locks.

Remove the ability to lock a tag's category. Before a moderator could
lock a tag such that only an admin could change the tag's category.

Nowadays the ability to change a tag's category is based on the tag's
size. Members can change tag categories for tags with up to 50 posts,
and Builders can change categories for tags with up to 1000 posts.
Manually locking tags is not necessary.

We only had a few dozen locked tags, mostly random *_(cosplay) tags or
company name tags. Most of these are holdovers from moderators randomly
locking tags like ten years ago.

The `is_locked` field is still in the database, so it is still returned
by the /tags.json API, even though it is unused.
This commit is contained in:
evazion
2021-12-09 13:20:26 -06:00
parent a28078fdaa
commit 208b618918
5 changed files with 5 additions and 36 deletions

View File

@@ -269,7 +269,7 @@ class Tag < ApplicationRecord
end
def search(params)
q = search_attributes(params, :id, :created_at, :updated_at, :is_locked, :category, :post_count, :name, :wiki_page, :artist, :antecedent_alias, :consequent_aliases, :antecedent_implications, :consequent_implications, :dtext_links)
q = search_attributes(params, :id, :created_at, :updated_at, :category, :post_count, :name, :wiki_page, :artist, :antecedent_alias, :consequent_aliases, :antecedent_implications, :consequent_implications, :dtext_links)
if params[:fuzzy_name_matches].present?
q = q.fuzzy_name_matches(params[:fuzzy_name_matches])

View File

@@ -1,15 +1,11 @@
class TagPolicy < ApplicationPolicy
def can_change_category?
user.is_admin? ||
(user.is_builder? && !record.is_locked? && record.post_count < 1_000) ||
(user.is_member? && !record.is_locked? && record.post_count < 50)
end
def can_lock?
user.is_moderator?
(user.is_builder? && record.post_count < 1_000) ||
(user.is_member? && record.post_count < 50)
end
def permitted_attributes
[(:category if can_change_category?), (:is_locked if can_lock?)].compact
[(:category if can_change_category?)].compact
end
end

View File

@@ -5,15 +5,10 @@
<%= edit_form_for(@tag) do |f| %>
<% if policy(@tag).can_change_category? %>
<%= f.input :category, collection: TagCategory.canonical_mapping.to_a, include_blank: false %>
<%= f.button :submit, "Submit" %>
<% else %>
<p>Create a <%= link_to "bulk update request", new_bulk_update_request_path(bulk_update_request: { script: "category #{@tag.name} -> general" }) %> to change this tag's category.</p>
<% end %>
<% if policy(@tag).can_lock? %>
<%= f.input :is_locked, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
<% end %>
<%= f.button :submit, "Submit" %>
<% end %>
</div>
</div>