aliases/implications: remove dead approving/updating code.
Remove the edit, update, and approve endpoints for tag aliases and implications. These have been useless since individual alias and implication requests were removed. Aliases and implications could only be edited or approved if they were in the pending state, which is no longer possible. Also remove unused new alias/implication request forms.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class TagAliasesController < ApplicationController
|
||||
before_action :admin_only, :only => [:approve, :new, :create]
|
||||
before_action :admin_only, only: [:destroy]
|
||||
respond_to :html, :xml, :json, :js
|
||||
|
||||
def show
|
||||
@@ -7,20 +7,6 @@ class TagAliasesController < ApplicationController
|
||||
respond_with(@tag_alias)
|
||||
end
|
||||
|
||||
def edit
|
||||
@tag_alias = TagAlias.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@tag_alias = TagAlias.find(params[:id])
|
||||
|
||||
if @tag_alias.is_pending? && @tag_alias.editable_by?(CurrentUser.user)
|
||||
@tag_alias.update(tag_alias_params)
|
||||
end
|
||||
|
||||
respond_with(@tag_alias)
|
||||
end
|
||||
|
||||
def index
|
||||
@tag_aliases = TagAlias.paginated_search(params, count_pages: true)
|
||||
@tag_aliases = @tag_aliases.includes(:antecedent_tag, :consequent_tag, :approver) if request.format.html?
|
||||
@@ -30,16 +16,9 @@ class TagAliasesController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@tag_alias = TagAlias.find(params[:id])
|
||||
raise User::PrivilegeError unless @tag_alias.deletable_by?(CurrentUser.user)
|
||||
|
||||
@tag_alias.reject!
|
||||
respond_with(@tag_alias, location: tag_aliases_path, notice: "Tag alias was deleted")
|
||||
end
|
||||
|
||||
def approve
|
||||
@tag_alias = TagAlias.find(params[:id])
|
||||
@tag_alias.approve!(approver: CurrentUser.user)
|
||||
respond_with(@tag_alias, :location => tag_alias_path(@tag_alias))
|
||||
respond_with(@tag_alias, location: tag_aliases_path, notice: "Tag alias was deleted")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class TagImplicationsController < ApplicationController
|
||||
before_action :admin_only, :only => [:new, :create, :approve]
|
||||
before_action :admin_only, only: [:destroy]
|
||||
respond_to :html, :xml, :json, :js
|
||||
|
||||
def show
|
||||
@@ -7,20 +7,6 @@ class TagImplicationsController < ApplicationController
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def edit
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
|
||||
if @tag_implication.is_pending? && @tag_implication.editable_by?(CurrentUser.user)
|
||||
@tag_implication.update(tag_implication_params)
|
||||
end
|
||||
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def index
|
||||
@tag_implications = TagImplication.paginated_search(params, count_pages: true)
|
||||
@tag_implications = @tag_implications.includes(:antecedent_tag, :consequent_tag, :approver) if request.format.html?
|
||||
@@ -30,16 +16,9 @@ class TagImplicationsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
raise User::PrivilegeError unless @tag_implication.deletable_by?(CurrentUser.user)
|
||||
|
||||
@tag_implication.reject!
|
||||
respond_with(@tag_implication, location: tag_implications_path, notice: "Tag implication was deleted")
|
||||
end
|
||||
|
||||
def approve
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
@tag_implication.approve!(approver: CurrentUser.user)
|
||||
respond_with(@tag_implication, :location => tag_implication_path(@tag_implication))
|
||||
respond_with(@tag_implication, location: tag_implications_path, notice: "Tag implication was deleted")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -366,10 +366,10 @@ module ApplicationHelper
|
||||
when "moderator/dashboards"
|
||||
/^\/moderator/
|
||||
|
||||
when "tag_aliases", "tag_alias_requests"
|
||||
when "tag_aliases"
|
||||
/^\/tag_aliases/
|
||||
|
||||
when "tag_implications", "tag_implication_requests"
|
||||
when "tag_implications",
|
||||
/^\/tag_implications/
|
||||
|
||||
when "wiki_pages", "wiki_page_versions"
|
||||
|
||||
@@ -66,14 +66,7 @@ class TagRelationship < ApplicationRecord
|
||||
end
|
||||
|
||||
def deletable_by?(user)
|
||||
return true if user.is_admin?
|
||||
return true if is_pending? && user.is_builder?
|
||||
return true if is_pending? && user.id == creator_id
|
||||
return false
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
deletable_by?(user)
|
||||
user.is_admin?
|
||||
end
|
||||
|
||||
def reject!(update_topic: true)
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<div id="c-tag-alias-requests">
|
||||
<div id="a-new">
|
||||
<h1>Tag Alias Request</h1>
|
||||
|
||||
<%= error_messages_for :tag_alias_request %>
|
||||
|
||||
<p>You can request a new tag alias be created. This will create a corresponding forum topic for community review.</p>
|
||||
|
||||
<%= form_tag(tag_alias_request_path, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<label>From</label>
|
||||
<%= text_field "tag_alias_request", "antecedent_name", :data => { :autocomplete => "tag" } %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label>To</label>
|
||||
<%= text_field "tag_alias_request", "consequent_name", :data => { :autocomplete => "tag" } %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= dtext_field "tag_alias_request", "reason", :name => "Reason" %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label class="checkbox optional" for="tag_alias_request_skip_secondary_validations">
|
||||
<%= check_box "tag_alias_request", "skip_secondary_validations" %>
|
||||
Skip validations
|
||||
</label>
|
||||
<p class="hint">You can ignore the wiki page and minimum count requirements</p>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= submit_tag "Submit" %>
|
||||
<%= dtext_preview_button "tag_alias_request", "reason" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "tag_aliases/secondary_links" %>
|
||||
@@ -21,16 +21,8 @@
|
||||
<% t.column column: "control", width: "15%" do |tag_alias| %>
|
||||
<%= link_to "Show", tag_alias_path(tag_alias) %>
|
||||
|
||||
<% if tag_alias.is_pending? && tag_alias.editable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Edit", edit_tag_alias_path(tag_alias) %>
|
||||
<% end %>
|
||||
|
||||
<% if tag_alias.deletable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.user.is_admin? && tag_alias.is_pending? %>
|
||||
| <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
$("#tag-alias-status-for-<%= @tag_alias.id %>").html("queued");
|
||||
@@ -1,16 +0,0 @@
|
||||
<div id="c-tag-aliases">
|
||||
<div id="a-new">
|
||||
<h1>Edit Tag Alias</h1>
|
||||
|
||||
<%= error_messages_for :tag_alias %>
|
||||
|
||||
<%= edit_form_for(@tag_alias) do |f| %>
|
||||
<%= f.input :antecedent_name, :as => :string, :label => "From" %>
|
||||
<%= f.input :consequent_name, :label => "To" %>
|
||||
<%= f.input :forum_topic_id, :label => "Forum" %>
|
||||
<%= f.button :submit, :data => { :disable_with => "Updating..." } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
@@ -19,10 +19,6 @@
|
||||
</li>
|
||||
<% end %>
|
||||
<li><strong>Status</strong> <%= @tag_alias.status %></li>
|
||||
|
||||
<% if CurrentUser.is_admin? && @tag_alias.is_pending? %>
|
||||
<li><strong>Commands</strong> <%= link_to "Approve", approve_tag_alias_path(@tag_alias), :method => :post %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<div id="c-tag-implication-requests">
|
||||
<div id="a-new">
|
||||
<h1>Tag Implication Request</h1>
|
||||
|
||||
<%= error_messages_for :tag_implication_request %>
|
||||
|
||||
<p>You can request a new tag implication be created. This will create a corresponding forum topic for community review.</p>
|
||||
|
||||
<%= form_tag(tag_implication_request_path, :class => "simple_form") do %>
|
||||
<div class="input">
|
||||
<label>From</label>
|
||||
<%= text_field "tag_implication_request", "antecedent_name", :data => { :autocomplete => "tag" } %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label>To</label>
|
||||
<%= text_field "tag_implication_request", "consequent_name", :data => { :autocomplete => "tag" } %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= dtext_field "tag_implication_request", "reason", :name => "Reason" %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label class="checkbox optional" for="tag_implication_request_skip_secondary_validations">
|
||||
<%= check_box "tag_implication_request", "skip_secondary_validations" %>
|
||||
Skip validations
|
||||
</label>
|
||||
<p class="hint">You can ignore the wiki page and minimum count requirements</p>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= submit_tag "Submit" %>
|
||||
<%= dtext_preview_button "tag_implication_request", "reason" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "tag_implications/secondary_links" %>
|
||||
@@ -21,16 +21,8 @@
|
||||
<% t.column column: "control", width: "15%" do |tag_implication| %>
|
||||
<%= link_to "Show", tag_implication_path(tag_implication) %>
|
||||
|
||||
<% if tag_implication.is_pending? && tag_implication.editable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Edit", edit_tag_implication_path(tag_implication) %>
|
||||
<% end %>
|
||||
|
||||
<% if tag_implication.deletable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
|
||||
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
$("#tag-implication-status-for-<%= @tag_implication.id %>").html("queued");
|
||||
@@ -1,16 +0,0 @@
|
||||
<div id="c-tag-implications">
|
||||
<div id="a-edit">
|
||||
<h1>Edit Tag Implication</h1>
|
||||
|
||||
<%= error_messages_for :tag_implication %>
|
||||
|
||||
<%= edit_form_for(@tag_implication) do |f| %>
|
||||
<%= f.input :antecedent_name, :label => "From" %>
|
||||
<%= f.input :consequent_name, :label => "To" %>
|
||||
<%= f.input :forum_topic_id, :label => "Forum" %>
|
||||
<%= f.button :submit, :data => { :disable_with => "Updating..." } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
@@ -19,10 +19,6 @@
|
||||
</li>
|
||||
<% end %>
|
||||
<li><strong>Status</strong>: <%= @tag_implication.status %></li>
|
||||
|
||||
<% if CurrentUser.is_admin? && @tag_implication.is_pending? %>
|
||||
<li><strong>Commands</strong> <%= link_to "Approve", approve_tag_implication_path(@tag_implication), :method => :post %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -241,16 +241,8 @@ Rails.application.routes.draw do
|
||||
get :autocomplete
|
||||
end
|
||||
end
|
||||
resources :tag_aliases do
|
||||
member do
|
||||
post :approve
|
||||
end
|
||||
end
|
||||
resources :tag_implications do
|
||||
member do
|
||||
post :approve
|
||||
end
|
||||
end
|
||||
resources :tag_aliases, only: [:show, :index, :destroy]
|
||||
resources :tag_implications, only: [:show, :index, :destroy]
|
||||
resources :uploads do
|
||||
collection do
|
||||
post :preprocess
|
||||
|
||||
@@ -7,50 +7,6 @@ class TagAliasesControllerTest < ActionDispatch::IntegrationTest
|
||||
@tag_alias = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
|
||||
end
|
||||
|
||||
context "edit action" do
|
||||
should "render" do
|
||||
get_auth edit_tag_alias_path(@tag_alias), @user
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "update action" do
|
||||
context "for a pending alias" do
|
||||
setup do
|
||||
as_admin do
|
||||
@tag_alias.update(status: "pending")
|
||||
end
|
||||
end
|
||||
|
||||
should "succeed" do
|
||||
put_auth tag_alias_path(@tag_alias), @user, params: {:tag_alias => {:antecedent_name => "xxx"}}
|
||||
@tag_alias.reload
|
||||
assert_equal("xxx", @tag_alias.antecedent_name)
|
||||
end
|
||||
|
||||
should "not allow changing the status" do
|
||||
put_auth tag_alias_path(@tag_alias), @user, params: {:tag_alias => {:status => "active"}}
|
||||
@tag_alias.reload
|
||||
assert_equal("pending", @tag_alias.status)
|
||||
end
|
||||
|
||||
# TODO: Broken in shoulda-matchers 2.8.0. Need to upgrade to 3.1.1.
|
||||
# should_eventually permit(:antecedent_name, :consequent_name, :forum_topic_id).for(:update)
|
||||
end
|
||||
|
||||
context "for an approved alias" do
|
||||
setup do
|
||||
@tag_alias.update_attribute(:status, "approved")
|
||||
end
|
||||
|
||||
should "fail" do
|
||||
put_auth tag_alias_path(@tag_alias), @user, params: {:tag_alias => {:antecedent_name => "xxx"}}
|
||||
@tag_alias.reload
|
||||
assert_equal("aaa", @tag_alias.antecedent_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "list all tag alias" do
|
||||
get_auth tag_aliases_path, @user
|
||||
|
||||
@@ -7,47 +7,6 @@ class TagImplicationsControllerTest < ActionDispatch::IntegrationTest
|
||||
@tag_implication = create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb")
|
||||
end
|
||||
|
||||
context "edit action" do
|
||||
should "render" do
|
||||
get_auth tag_implication_path(@tag_implication), @user
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "update action" do
|
||||
context "for a pending implication" do
|
||||
setup do
|
||||
as_admin do
|
||||
@tag_implication.update(status: "pending")
|
||||
end
|
||||
end
|
||||
|
||||
should "succeed" do
|
||||
put_auth tag_implication_path(@tag_implication), @user, params: {:tag_implication => {:antecedent_name => "xxx"}}
|
||||
@tag_implication.reload
|
||||
assert_equal("xxx", @tag_implication.antecedent_name)
|
||||
end
|
||||
|
||||
should "not allow changing the status" do
|
||||
put_auth tag_implication_path(@tag_implication), @user, params: {:tag_implication => {:status => "active"}}
|
||||
@tag_implication.reload
|
||||
assert_equal("pending", @tag_implication.status)
|
||||
end
|
||||
end
|
||||
|
||||
context "for an approved implication" do
|
||||
setup do
|
||||
@tag_implication.update_attribute(:status, "approved")
|
||||
end
|
||||
|
||||
should "fail" do
|
||||
put_auth tag_implication_path(@tag_implication), @user, params: {:tag_implication => {:antecedent_name => "xxx"}}
|
||||
@tag_implication.reload
|
||||
assert_equal("aaa", @tag_implication.antecedent_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "list all tag implications" do
|
||||
get tag_implications_path
|
||||
|
||||
Reference in New Issue
Block a user