From 9c70b69d28d6c675c1cb3fcf582112be32d3c0e8 Mon Sep 17 00:00:00 2001 From: Toks Date: Mon, 29 Jun 2015 15:01:41 -0400 Subject: [PATCH] fixes #2422 --- app/models/post.rb | 13 +++++++++++-- app/presenters/post_presenter.rb | 2 +- .../posts/partials/show/_favorite_groups.html.erb | 2 +- app/views/posts/partials/show/_nav_links.html.erb | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index a8e8fbc40..9f3c2b269 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -838,11 +838,20 @@ class Post < ActiveRecord::Base favorited_user_ids.map {|id| User.find(id)} end - def favorite_groups + def favorite_groups(active_id=nil) @favorite_groups ||= begin - CurrentUser.user.favorite_groups.select do |favgroup| + groups = [] + + if active_id.present? + active_group = FavoriteGroup.where(:id => active_id.to_i).first + groups << active_group if active_group && active_group.contains?(self.id) + end + + groups += CurrentUser.user.favorite_groups.select do |favgroup| favgroup.contains?(self.id) end + + groups.uniq end end end diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 81a518fe7..e469a25f3 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -205,7 +205,7 @@ class PostPresenter < Presenter end def has_nav_links?(template) - (CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups.any? + (CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any? end def post_footer_for_pool_html(template) diff --git a/app/views/posts/partials/show/_favorite_groups.html.erb b/app/views/posts/partials/show/_favorite_groups.html.erb index f962ae62c..581df4169 100644 --- a/app/views/posts/partials/show/_favorite_groups.html.erb +++ b/app/views/posts/partials/show/_favorite_groups.html.erb @@ -1,6 +1,6 @@