BUGFIX: don't show redirect reason if you aren't redirected

Move the redirect to top page logic server-side and make sure the reason
is not shown when top is not in the navigation menu (top_menu).
This commit is contained in:
Régis Hanol
2014-03-07 18:58:53 +01:00
parent c3e5ee1d7e
commit 8214536614
12 changed files with 122 additions and 117 deletions

View File

@@ -9,8 +9,7 @@ class SiteSerializer < ApplicationSerializer
:top_menu_items,
:anonymous_top_menu_items,
:uncategorized_category_id, # this is hidden so putting it here
:is_readonly,
:has_enough_topic_to_redirect_to_top_page
:is_readonly
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
has_many :post_action_types, embed: :objects
@@ -51,12 +50,4 @@ class SiteSerializer < ApplicationSerializer
Discourse.readonly_mode?
end
def has_enough_topic_to_redirect_to_top_page
Topic.listable_topics
.visible
.includes(:category).references(:category)
.where('COALESCE(categories.topic_id, 0) <> topics.id')
.count > SiteSetting.topics_per_period_in_top_page
end
end