add link for migrating tag subscription to saved search

This commit is contained in:
r888888888
2016-06-15 13:39:16 -07:00
parent 3e3f90d79a
commit 4622656abb
4 changed files with 12 additions and 0 deletions

View File

@@ -61,6 +61,14 @@ class TagSubscriptionsController < ApplicationController
@posts = @post_set.posts @posts = @post_set.posts
end end
def migrate
@tag_subscription = TagSubscription.find(params[:id])
check_privilege(@tag_subscription)
@tag_subscription.migrate_to_saved_searches
flash[:notice] = "Tag subscription will be migrated to a saved search. Please wait a few minutes for the search to refresh."
redirect_to tag_subscriptions_path
end
private private
def check_privilege(tag_subscription) def check_privilege(tag_subscription)
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user) raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)

View File

@@ -16,6 +16,8 @@ class TagSubscription < ActiveRecord::Base
:category => name :category => name
) )
end end
destroy
end end
def normalize_name def normalize_name

View File

@@ -20,6 +20,7 @@
<%= link_to "edit", edit_tag_subscription_path(tag_subscription) %> <%= link_to "edit", edit_tag_subscription_path(tag_subscription) %>
| <%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %> | <%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %>
| <%= link_to "posts", posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}"), :rel => "nofollow" %> | <%= link_to "posts", posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}"), :rel => "nofollow" %>
| <%= link_to "migrate", migrate_tag_subscription_path(tag_subscription), :method => :post %>
</td> </td>
</tr> </tr>
<% end %> <% end %>

View File

@@ -257,6 +257,7 @@ Rails.application.routes.draw do
resource :tag_implication_request, :only => [:new, :create] resource :tag_implication_request, :only => [:new, :create]
resources :tag_subscriptions do resources :tag_subscriptions do
member do member do
post :migrate
get :posts get :posts
end end
end end