add saved search gallery link, can only view your own saved searches, normalize saved search categories
This commit is contained in:
@@ -103,16 +103,10 @@ class PostQueryBuilder
|
||||
|
||||
def add_saved_search_relation(saved_searches, relation)
|
||||
saved_searches.each do |saved_search|
|
||||
if saved_search =~ /^(.+?):(.+)$/
|
||||
user_name = $1
|
||||
name = $2
|
||||
user = User.find_by_name(user_name)
|
||||
return relation if user.nil?
|
||||
post_ids = SavedSearch.post_ids(user.id, name)
|
||||
if saved_search == "all"
|
||||
post_ids = SavedSearch.post_ids(CurrentUser.id)
|
||||
else
|
||||
user = User.find_by_name(saved_search)
|
||||
return relation if user.nil?
|
||||
post_ids = SavedSearch.post_ids(user.id, nil)
|
||||
post_ids = SavedSearch.post_ids(CurrentUser.id, saved_search)
|
||||
end
|
||||
|
||||
post_ids = [0] if post_ids.empty?
|
||||
|
||||
@@ -109,6 +109,7 @@ class SavedSearch < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def normalize
|
||||
self.category = category.strip.gsub(/\s+/, "_").downcase if category
|
||||
self.tag_query = SavedSearch.normalize(tag_query)
|
||||
end
|
||||
|
||||
|
||||
@@ -460,10 +460,8 @@ class User < ActiveRecord::Base
|
||||
def max_saved_searches
|
||||
if is_platinum?
|
||||
1_000
|
||||
elsif is_gold?
|
||||
200
|
||||
else
|
||||
100
|
||||
250
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
6
app/views/saved_searches/_secondary_links.html.erb
Normal file
6
app/views/saved_searches/_secondary_links.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "Gallery", posts_path(:tags => "search:all") %></li>
|
||||
<li><%= link_to "Listing", saved_searches_path %></li>
|
||||
</menu>
|
||||
<% end %>
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Edit Saved Search - <%= Danbooru.config.app_name %>
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
<h1>Saved Searches</h1>
|
||||
|
||||
<% @categories.each do |category, saved_searches| %>
|
||||
<h2><%= category.present? ? category : "Uncategorized" %></h2>
|
||||
<h2>
|
||||
<% if category.present? %>
|
||||
<%= link_to category, posts_path(:tags => "search:#{category}") %>
|
||||
<% else %>
|
||||
Uncategorized
|
||||
<% end %>
|
||||
</h2>
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -27,7 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Saved Searches - <%= Danbooru.config.app_name %>
|
||||
|
||||
15
script/fixes/039_fix_saved_search_categories.rb
Normal file
15
script/fixes/039_fix_saved_search_categories.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||
|
||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||
|
||||
CurrentUser.user = User.admins.first
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
SavedSearch.where("category is not null and category <> ''").find_each do |ss|
|
||||
print ss.category + " -> "
|
||||
ss.normalize
|
||||
puts ss.category
|
||||
ss.save
|
||||
end
|
||||
Reference in New Issue
Block a user