Fix #4601: Hide deleted pools by default in pool search.
* On /pools, hide deleted pools by default in HTML responses. Don't filter out deleted pools in API responses. * API change: on /forum_topics, only hide deleted forum topics by default for HTML responses, not for API responses. Explicitly do https://danbooru.donmai.us/forum_topics.json?search[is_deleted]=false to filter out deleted topics. * API change: on /tags, only hide empty tags by default for HTML responses, not for API responses. Explicitly do https://danbooru.donmai.us/tags.json?search[is_empty]=false to filter out empty tags. * API change: on /pools, default to 20 posts per page for API responses, not 40. * API change: add `search[is_empty]` param to /tags.json endpoint. `search[hide_empty]=true` is deprecated in favor of `search[is_empty]=false`. * On /pools, add option to show/hide deleted pools in search form. * Fix the /forum_topics page putting `search[order]=sticky&limit=40` in the URL when browsing past page 1.
This commit is contained in:
@@ -15,11 +15,12 @@ class ForumTopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
params[:search] ||= {}
|
||||
params[:search][:order] ||= "sticky" if request.format.html?
|
||||
params[:limit] ||= 40
|
||||
|
||||
@forum_topics = authorize ForumTopic.visible(CurrentUser.user).paginated_search(params)
|
||||
if request.format.html?
|
||||
limit = params.fetch(:limit, 40)
|
||||
@forum_topics = authorize ForumTopic.visible(CurrentUser.user).paginated_search(params, limit: limit, defaults: { order: "sticky", is_deleted: false })
|
||||
else
|
||||
@forum_topics = authorize ForumTopic.visible(CurrentUser.user).paginated_search(params)
|
||||
end
|
||||
|
||||
if request.format.atom?
|
||||
@forum_topics = @forum_topics.includes(:creator, :original_post)
|
||||
|
||||
@@ -12,7 +12,11 @@ class PoolsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@pools = authorize Pool.paginated_search(params, count_pages: true)
|
||||
if request.format.html?
|
||||
@pools = authorize Pool.paginated_search(params, count_pages: true, defaults: { is_deleted: false })
|
||||
else
|
||||
@pools = authorize Pool.paginated_search(params, count_pages: true)
|
||||
end
|
||||
|
||||
respond_with(@pools)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,12 @@ class TagsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@tags = authorize Tag.paginated_search(params, hide_empty: true)
|
||||
if request.format.html?
|
||||
@tags = authorize Tag.paginated_search(params, defaults: { hide_empty: true })
|
||||
else
|
||||
@tags = authorize Tag.paginated_search(params)
|
||||
end
|
||||
|
||||
@tags = @tags.includes(:consequent_aliases) if request.format.html?
|
||||
respond_with(@tags)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user