allow editing of pending aliases/implications
This commit is contained in:
@@ -12,6 +12,20 @@ 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_attributes(params[:tag_alias])
|
||||
end
|
||||
|
||||
respond_with(@tag_alias)
|
||||
end
|
||||
|
||||
def index
|
||||
@search = TagAlias.search(params[:search])
|
||||
@tag_aliases = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page], :limit => params[:limit])
|
||||
|
||||
@@ -12,6 +12,20 @@ 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_attributes(params[:tag_implication])
|
||||
end
|
||||
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def index
|
||||
@search = TagImplication.search(params[:search])
|
||||
@tag_implications = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page], :limit => params[:limit])
|
||||
|
||||
@@ -222,4 +222,8 @@ class TagAlias < ActiveRecord::Base
|
||||
return true if is_pending? && user.id == creator_id
|
||||
return false
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
deletable_by?(user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -211,4 +211,8 @@ class TagImplication < ActiveRecord::Base
|
||||
return true if is_pending? && user.id == creator_id
|
||||
return false
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
deletable_by?(user)
|
||||
end
|
||||
end
|
||||
|
||||
20
app/views/tag_aliases/edit.html.erb
Normal file
20
app/views/tag_aliases/edit.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<div id="c-tag-aliases">
|
||||
<div id="a-new">
|
||||
<h1>Edit Tag Alias</h1>
|
||||
|
||||
<%= error_messages_for :tag_alias %>
|
||||
|
||||
<%= simple_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 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Edit Tag Alias - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -32,6 +32,11 @@
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", tag_alias_path(tag_alias) %>
|
||||
|
||||
<% if 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 %>
|
||||
|
||||
20
app/views/tag_implications/edit.html.erb
Normal file
20
app/views/tag_implications/edit.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<div id="c-tag-aliases">
|
||||
<div id="a-new">
|
||||
<h1>Edit Tag Implication</h1>
|
||||
|
||||
<%= error_messages_for :tag_implication %>
|
||||
|
||||
<%= simple_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 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Edit Tag Implication - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -30,9 +30,15 @@
|
||||
<td id="tag-implication-status-for-<%= tag_implication.id %>"><%= tag_implication.status %></td>
|
||||
<td>
|
||||
<%= link_to "Show", tag_implication_path(tag_implication) %>
|
||||
|
||||
<% if 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 %>
|
||||
|
||||
Reference in New Issue
Block a user