add link for migrating tag subscription to saved search
This commit is contained in:
@@ -61,6 +61,14 @@ class TagSubscriptionsController < ApplicationController
|
||||
@posts = @post_set.posts
|
||||
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
|
||||
def check_privilege(tag_subscription)
|
||||
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)
|
||||
|
||||
@@ -16,6 +16,8 @@ class TagSubscription < ActiveRecord::Base
|
||||
:category => name
|
||||
)
|
||||
end
|
||||
|
||||
destroy
|
||||
end
|
||||
|
||||
def normalize_name
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<%= 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 "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>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -257,6 +257,7 @@ Rails.application.routes.draw do
|
||||
resource :tag_implication_request, :only => [:new, :create]
|
||||
resources :tag_subscriptions do
|
||||
member do
|
||||
post :migrate
|
||||
get :posts
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user