reduce duplication
This commit is contained in:
parent
4b28bfaa15
commit
040e10a627
|
@ -278,7 +278,7 @@ class ListController < ApplicationController
|
||||||
|
|
||||||
def build_topic_list_options
|
def build_topic_list_options
|
||||||
options = {}
|
options = {}
|
||||||
TopicQuery.valid_options.each do |key|
|
TopicQuery.public_valid_options.each do |key|
|
||||||
options[key] = params[key]
|
options[key] = params[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -286,11 +286,6 @@ class ListController < ApplicationController
|
||||||
options[:topic_ids] = param_to_integer_list(:topic_ids)
|
options[:topic_ids] = param_to_integer_list(:topic_ids)
|
||||||
options[:no_subcategories] = options[:no_subcategories] == 'true'
|
options[:no_subcategories] = options[:no_subcategories] == 'true'
|
||||||
options[:slow_platform] = slow_platform?
|
options[:slow_platform] = slow_platform?
|
||||||
options.delete(:per_page)
|
|
||||||
options.delete(:limit)
|
|
||||||
options.delete(:except_topic_ids)
|
|
||||||
options.delete(:visible)
|
|
||||||
options.delete(:no_definitions)
|
|
||||||
|
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,32 +10,38 @@ require_dependency 'avatar_lookup'
|
||||||
|
|
||||||
class TopicQuery
|
class TopicQuery
|
||||||
|
|
||||||
|
def self.public_valid_options
|
||||||
|
@public_valid_options ||=
|
||||||
|
%i(page
|
||||||
|
topic_ids
|
||||||
|
exclude_category_ids
|
||||||
|
category
|
||||||
|
order
|
||||||
|
ascending
|
||||||
|
min_posts
|
||||||
|
max_posts
|
||||||
|
status
|
||||||
|
filter
|
||||||
|
state
|
||||||
|
search
|
||||||
|
q
|
||||||
|
group_name
|
||||||
|
tags
|
||||||
|
match_all_tags
|
||||||
|
no_subcategories
|
||||||
|
slow_platform
|
||||||
|
no_tags)
|
||||||
|
end
|
||||||
|
|
||||||
def self.valid_options
|
def self.valid_options
|
||||||
@valid_options ||=
|
@valid_options ||=
|
||||||
|
public_valid_options +
|
||||||
%i(except_topic_ids
|
%i(except_topic_ids
|
||||||
exclude_category_ids
|
|
||||||
limit
|
limit
|
||||||
page
|
page
|
||||||
per_page
|
per_page
|
||||||
min_posts
|
|
||||||
max_posts
|
|
||||||
topic_ids
|
|
||||||
visible
|
visible
|
||||||
category
|
no_definitions)
|
||||||
tags
|
|
||||||
match_all_tags
|
|
||||||
no_tags
|
|
||||||
order
|
|
||||||
ascending
|
|
||||||
no_subcategories
|
|
||||||
no_definitions
|
|
||||||
status
|
|
||||||
state
|
|
||||||
search
|
|
||||||
slow_platform
|
|
||||||
filter
|
|
||||||
group_name
|
|
||||||
q)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,11 +65,13 @@ class TopicQuery
|
||||||
def self.add_custom_filter(key, &blk)
|
def self.add_custom_filter(key, &blk)
|
||||||
@custom_filters ||= {}
|
@custom_filters ||= {}
|
||||||
valid_options << key
|
valid_options << key
|
||||||
|
public_valid_options << key
|
||||||
@custom_filters[key] = blk
|
@custom_filters[key] = blk
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.remove_custom_filter(key)
|
def self.remove_custom_filter(key)
|
||||||
@custom_filters.delete(key)
|
@custom_filters.delete(key)
|
||||||
|
public_valid_options.delete(key)
|
||||||
valid_options.delete(key)
|
valid_options.delete(key)
|
||||||
@custom_filters = nil if @custom_filters.length == 0
|
@custom_filters = nil if @custom_filters.length == 0
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue