diff --git a/app/controllers/tag_subscriptions_controller.rb b/app/controllers/tag_subscriptions_controller.rb index 9791be938..47cee7392 100644 --- a/app/controllers/tag_subscriptions_controller.rb +++ b/app/controllers/tag_subscriptions_controller.rb @@ -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) diff --git a/app/models/tag_subscription.rb b/app/models/tag_subscription.rb index 0a6ad7655..85051c674 100644 --- a/app/models/tag_subscription.rb +++ b/app/models/tag_subscription.rb @@ -16,6 +16,8 @@ class TagSubscription < ActiveRecord::Base :category => name ) end + + destroy end def normalize_name diff --git a/app/views/tag_subscriptions/index.html.erb b/app/views/tag_subscriptions/index.html.erb index 950cd5bab..009ccf7d3 100644 --- a/app/views/tag_subscriptions/index.html.erb +++ b/app/views/tag_subscriptions/index.html.erb @@ -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 %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index f5fc9506d..34690630f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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