Add ability to mark tags as deprecated

* Deprecated tags can't be added to posts, but existing deprecated tags
  in a post won't be removed
* Only empty tags can be marked as deprecated manually
* No tags can be manually undeprecated
** These limits don't apply to admins
* Deprecating or undeprecating a tag will create a new mod action to
  prevent people from going rogue
* Added deprecate/undeprecate commands for BURs
* Deprecating a tag via BUR removes all implications to and from it as well
This commit is contained in:
nonamethanks
2022-04-08 00:51:53 +02:00
parent 98a9b2484b
commit ea76a889db
16 changed files with 194 additions and 5 deletions

View File

@@ -121,6 +121,10 @@
<%= format_text(wiki_page.body) %>
<%= render "tag_relationships/alias_and_implication_list", tag: wiki_page.tag %>
<% if wiki_page.tag&.is_deprecated? %>
<p class="fineprint">This tag is <%= link_to "deprecated", wiki_page_path("help:deprecation_notice") %> and can't be added to new posts.</p>
<% end %>
<p class="mt-4">
<%= link_to_wiki "View wiki", wiki_page.title, id: "view-wiki-link" %>
</p>
@@ -154,6 +158,10 @@
<p>There is no wiki page yet for the tag <%= link_to_wiki @post_set.tag.pretty_name %>. <%= link_to "Create new wiki page", new_wiki_page_path(wiki_page: { title: @post_set.tag.name }), rel: "nofollow" %>.</p>
<%= render "tag_relationships/alias_and_implication_list", tag: @post_set.tag %>
<% if @post_set.tag&.is_deprecated? %>
<p class="fineprint">This tag is <%= link_to "deprecated", wiki_page_path("help:deprecation_notice") %> and can't be added to new posts.</p>
<% end %>
<% end %>
</div>

View File

@@ -2,6 +2,7 @@
<%= f.input :name_or_alias_matches, label: "Name", input_html: { value: params[:search][:name_or_alias_matches], data: { autocomplete: "tag" } } %>
<%= f.input :category, label: "Category", collection: TagCategory.canonical_mapping.to_a, include_blank: true,selected: params[:search][:category] %>
<%= f.input :order, collection: [%w[Newest date], %w[Count count], %w[Name name]], include_blank: false, selected: params[:search][:order] %>
<%= f.input :is_deprecated, label: "Is deprecated?", collection: %w[yes no], include_blank: true, selected: params[:search][:is_deprecated] %>
<%= f.input :hide_empty, label: "Hide empty?", collection: %w[yes no], selected: params[:search][:hide_empty] %>
<%= f.input :has_wiki_page, label: "Has wiki?", collection: %w[yes no], include_blank: true, selected: params[:search][:has_wiki_page] %>
<%= f.input :has_artist, label: "Has artist?", collection: %w[yes no], include_blank: true, selected: params[:search][:has_artist] %>

View File

@@ -5,10 +5,20 @@
<%= 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_change_deprecated_status? %>
<%= f.input :is_deprecated, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
<% else %>
<% if @tag.is_deprecated? %>
<p>Create a <%= link_to "bulk update request", new_bulk_update_request_path(bulk_update_request: { script: "deprecate #{@tag.name}" }) %> to mark this tag as not deprecated.</p>
<% else %>
<p>Create a <%= link_to "bulk update request", new_bulk_update_request_path(bulk_update_request: { script: "undeprecate #{@tag.name}" }) %> to mark this tag as deprecated.</p>
<% end %>
<% end %>
<%= f.button :submit, "Submit" %>
<% end %>
</div>
</div>

View File

@@ -8,6 +8,9 @@
<ul>
<li>Count: <%= @tag.post_count %></li>
<li>Category: <%= @tag.category_name %></li>
<% if @tag.is_deprecated? %>
<li> This tag is <%= link_to "deprecated", wiki_page_path("help:deprecation_notice") %> and can't be added to new posts.</li>
<% end %>
</ul>
</div>
</div>

View File

@@ -18,6 +18,11 @@
<% end %>
<%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %>
<% if @wiki_page.tag&.is_deprecated? %>
<p class="fineprint">This tag is <%= link_to "deprecated", wiki_page_path("help:deprecation_notice") %> and can't be added to new posts.</p>
<% end %>
<%= render "wiki_pages/posts", wiki_page: @wiki_page %>
<% end %>

View File

@@ -37,6 +37,10 @@
<% end %>
<%= render "tag_relationships/alias_and_implication_list", tag: @wiki_page.tag %>
<% if @wiki_page.tag&.is_deprecated? %>
<p class="fineprint">This tag is <%= link_to "deprecated", wiki_page_path("help:deprecation_notice") %> and can't be added to new posts.</p>
<% end %>
</div>
<%= render "wiki_pages/posts", wiki_page: @wiki_page %>