forked from e621ng/e621ng
remove references to tag subscriptions
This commit is contained in:
parent
09234dca4f
commit
e70c2a3085
@ -1,31 +0,0 @@
|
||||
class TagSubscriptionsController < ApplicationController
|
||||
before_filter :member_only, :only => [:destroy, :migrate]
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def index
|
||||
@user = CurrentUser.user
|
||||
@query = TagSubscription.order("name").search(params[:search])
|
||||
@tag_subscriptions = @query.paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@tag_subscriptions)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@tag_subscription = TagSubscription.find(params[:id])
|
||||
check_privilege(@tag_subscription)
|
||||
@tag_subscription.destroy
|
||||
respond_with(@tag_subscription)
|
||||
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)
|
||||
end
|
||||
end
|
@ -186,7 +186,7 @@ module ApplicationHelper
|
||||
protected
|
||||
def nav_link_match(controller, url)
|
||||
url =~ case controller
|
||||
when "sessions", "users", "maintenance/user/login_reminders", "maintenance/user/password_resets", "admin/users", "tag_subscriptions"
|
||||
when "sessions", "users", "maintenance/user/login_reminders", "maintenance/user/password_resets", "admin/users"
|
||||
/^\/(session|users)/
|
||||
|
||||
when "forum_posts"
|
||||
|
@ -68,10 +68,6 @@ class AnonymousUser
|
||||
true
|
||||
end
|
||||
|
||||
def tag_subscriptions
|
||||
[]
|
||||
end
|
||||
|
||||
def favorite_tags
|
||||
nil
|
||||
end
|
||||
|
@ -21,7 +21,6 @@ class UserDeletion
|
||||
validate
|
||||
clear_user_settings
|
||||
remove_favorites
|
||||
clear_tag_subscriptions
|
||||
clear_saved_searches
|
||||
rename
|
||||
reset_password
|
||||
@ -34,10 +33,6 @@ private
|
||||
ModAction.log("user ##{user.id} deleted")
|
||||
end
|
||||
|
||||
def clear_tag_subscriptions
|
||||
TagSubscription.where(:creator_id => user.id).destroy_all
|
||||
end
|
||||
|
||||
def clear_saved_searches
|
||||
SavedSearch.where(user_id: user.id).destroy_all
|
||||
end
|
||||
|
@ -97,7 +97,6 @@ class User < ApplicationRecord
|
||||
has_one :dmail_filter
|
||||
has_one :super_voter
|
||||
has_one :token_bucket
|
||||
has_many :subscriptions, lambda {order("tag_subscriptions.name")}, :class_name => "TagSubscription", :foreign_key => "creator_id"
|
||||
has_many :note_versions, :foreign_key => "updater_id"
|
||||
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
|
||||
has_many :saved_searches
|
||||
|
@ -43,7 +43,6 @@
|
||||
<li><%= link_to("Cheat sheet", wiki_pages_path(:title => "help:cheatsheet")) %></li>
|
||||
<li><%= link_to("Aliases", tag_aliases_path) %></li>
|
||||
<li><%= link_to("Implications", tag_implications_path) %></li>
|
||||
<li><%= link_to("Subscriptions",tag_subscriptions_path) %></li>
|
||||
<li><%= link_to("Listing", tags_path) %></li>
|
||||
</ul>
|
||||
<ul>
|
||||
|
@ -1,12 +0,0 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "Listing", tag_subscriptions_path %></li>
|
||||
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_subscriptions") %></li>
|
||||
|
||||
<% if @tag_subscription && !@tag_subscription.new_record? && @tag_subscription.editable_by?(CurrentUser.user) %>
|
||||
<li>|</li>
|
||||
<li><%= link_to "Show", tag_subscription_path(@tag_subscription) %></li>
|
||||
<li><%= link_to "Delete", tag_subscription_path(@tag_subscription, :method => :delete, :data => {:confirm => "Are you sure you want to delete this tag subscription?"}) %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
<% end %>
|
@ -1,35 +0,0 @@
|
||||
<div id="c-tag-subscriptions">
|
||||
<div id="a-index">
|
||||
<h1>Tag Subscriptions</h1>
|
||||
|
||||
<p class="info">The tag subscription feature is being deprecated. You can move your current tag subscriptions to saved searches by clicking the "migrate" link below.</p>
|
||||
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Tag Query</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @tag_subscriptions.each do |tag_subscription| %>
|
||||
<tr>
|
||||
<td><%= tag_subscription.pretty_name %></td>
|
||||
<td><%= tag_subscription.pretty_tag_query %></td>
|
||||
<td>
|
||||
<%= link_to "delete", tag_subscription_path(tag_subscription), :method => :delete, :data => {:confirm => "Are you sure you want to delete this subscription?"} %>
|
||||
| <%= link_to "migrate", migrate_tag_subscription_path(tag_subscription), :method => :post %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Tag Subscriptions - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
@ -161,13 +161,6 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th>Subscriptions</th>
|
||||
<td>
|
||||
<em>This feature has been disabled. <%= link_to "Migrate your tag subscriptions to saved searches", tag_subscriptions_path %>.</em>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>API Key</th>
|
||||
<td>
|
||||
|
@ -169,21 +169,11 @@ module Danbooru
|
||||
end
|
||||
end
|
||||
|
||||
# Max number of posts to cache
|
||||
def tag_subscription_post_limit
|
||||
200
|
||||
end
|
||||
|
||||
# After this many pages, the paginator will switch to sequential mode.
|
||||
def max_numbered_pages
|
||||
1_000
|
||||
end
|
||||
|
||||
# Max number of tag subscriptions per user
|
||||
def max_tag_subscriptions
|
||||
5
|
||||
end
|
||||
|
||||
# Maximum size of an upload.
|
||||
def max_file_size
|
||||
35.megabytes
|
||||
|
@ -27,9 +27,6 @@ en:
|
||||
comment_vote:
|
||||
comment: "You"
|
||||
user_id: "You"
|
||||
tag_subscription:
|
||||
creator: "You"
|
||||
creator_id: "You"
|
||||
upload:
|
||||
uploader: "You"
|
||||
uploader_id: "You"
|
||||
|
@ -276,11 +276,6 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
resource :tag_implication_request, :only => [:new, :create]
|
||||
resources :tag_subscriptions, :only => [:index, :destroy, :migrate] do
|
||||
member do
|
||||
post :migrate
|
||||
end
|
||||
end
|
||||
resources :uploads do
|
||||
collection do
|
||||
get :batch
|
||||
|
12
db/seeds.rb
12
db/seeds.rb
@ -216,15 +216,3 @@ if ForumTopic.count == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if TagSubscription.count == 0
|
||||
puts "Creating tag subscriptions"
|
||||
TagSubscription.create(:name => "0", :tag_query => Tag.order("random()").first.name)
|
||||
1.upto(50) do |i|
|
||||
CurrentUser.user = User.order("random()").first
|
||||
TagSubscription.create(:name => i.to_s, :tag_query => Tag.order("random()").first.name)
|
||||
end
|
||||
else
|
||||
puts "Skipping tag subscriptions"
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,6 @@ Disallow: /tag_aliases
|
||||
Disallow: /tag_corrections
|
||||
Disallow: /tag_implication_requests
|
||||
Disallow: /tag_implications
|
||||
Disallow: /tag_subscriptions
|
||||
Disallow: /tags
|
||||
Disallow: /uploads
|
||||
Disallow: /user_feedback
|
||||
|
@ -1,7 +0,0 @@
|
||||
FactoryGirl.define do
|
||||
factory(:tag_subscription) do
|
||||
name {FFaker::Lorem.words.join(" ")}
|
||||
is_public true
|
||||
tag_query "aaa"
|
||||
end
|
||||
end
|
@ -1,39 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagSubscriptionsControllerTest < ActionController::TestCase
|
||||
context "The tag subscriptions controller" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa")
|
||||
end
|
||||
|
||||
should "list all visible tag subscriptions" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@tag_subscription = FactoryGirl.create(:tag_subscription)
|
||||
end
|
||||
|
||||
should "destroy the posts" do
|
||||
assert_difference("TagSubscription.count", -1) do
|
||||
post :destroy, {:id => @tag_subscription.id}, {:user_id => @user.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,26 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagSubscriptionTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
user = FactoryGirl.create(:user)
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "A tag subscription" do
|
||||
should "migrate to saved searches" do
|
||||
sub = FactoryGirl.create(:tag_subscription, tag_query: "foo bar\r\nbar\nbaz", :name => "Artist 1")
|
||||
sub.migrate_to_saved_searches
|
||||
|
||||
assert_equal(1, CurrentUser.user.subscriptions.size)
|
||||
assert_equal(3, CurrentUser.user.saved_searches.size)
|
||||
assert_equal(["foo bar", "bar", "baz"], CurrentUser.user.saved_searches.pluck(:query))
|
||||
assert_equal([%w[artist_1]]*3, CurrentUser.user.saved_searches.pluck(:labels))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user