fixes #2422
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div id="favgroup-nav">
|
||||
<ul>
|
||||
<% post.favorite_groups.each do |favgroup| %>
|
||||
<% post.favorite_groups(active_id=params[:favgroup_id]).each do |favgroup| %>
|
||||
<li>
|
||||
<% klass = "active" if favgroup.id == params[:favgroup_id].to_i %>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<%= render "posts/partials/show/pools", :post => post %>
|
||||
<% end %>
|
||||
|
||||
<% if post.favorite_groups.any? %>
|
||||
<% if post.favorite_groups(active_id=params[:favgroup_id]).any? %>
|
||||
<%= render "posts/partials/show/favorite_groups", :post => post %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user