Support for "no subcategories"

This commit is contained in:
Robin Ward
2013-12-13 17:18:28 -05:00
parent ccd0f9c371
commit acf262b631
14 changed files with 98 additions and 35 deletions

View File

@ -47,11 +47,11 @@ class ListController < ApplicationController
end
def category
list_opts = build_topic_list_options
query = TopicQuery.new(current_user, list_opts)
list = query.list_latest
list.more_topics_url = construct_url_with(:latest, list_opts)
respond(list)
category_response
end
def category_none
category_response(no_subcategories: true)
end
def category_feed
@ -74,6 +74,15 @@ class ListController < ApplicationController
protected
def category_response(extra_opts=nil)
list_opts = build_topic_list_options
list_opts.merge!(extra_opts) if extra_opts
query = TopicQuery.new(current_user, list_opts)
list = query.list_latest
list.more_topics_url = construct_url_with(:latest, list_opts)
respond(list)
end
def respond(list)
list.draft_key = Draft::NEW_TOPIC
@ -128,14 +137,16 @@ class ListController < ApplicationController
menu_item = menu_items.select { |item| item.query_should_exclude_category?(action_name, params[:format]) }.first
# exclude_category = 1. from params / 2. parsed from top menu / 3. nil
return {
result = {
page: params[:page],
topic_ids: param_to_integer_list(:topic_ids),
exclude_category: (params[:exclude_category] || menu_item.try(:filter)),
category: params[:category],
sort_order: params[:sort_order],
sort_descending: params[:sort_descending]
sort_descending: params[:sort_descending],
}
result[:no_subcategories] = true if params[:no_subcategories] == 'true'
result
end
def list_target_user