post sets: refactor pool/favgroup methods.
Eliminate the `has_pool?` and `pool_name` methods in favor of the `pool` method. Likewise for favgroups.
This commit is contained in:
@@ -41,28 +41,18 @@ module PostSets
|
|||||||
tag.artist
|
tag.artist
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool_name
|
|
||||||
@pool_name ||= Tag.has_metatag?(tag_array, :ordpool, :pool)
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_pool?
|
|
||||||
is_single_tag? && pool_name && pool
|
|
||||||
end
|
|
||||||
|
|
||||||
def pool
|
def pool
|
||||||
::Pool.find_by_name(pool_name)
|
name = Tag.has_metatag?(tag_array, :ordpool, :pool)
|
||||||
end
|
return nil unless is_single_tag? && name.present?
|
||||||
|
|
||||||
def favgroup_name
|
@pool ||= Pool.find_by_name(name)
|
||||||
@favgroup_name ||= Tag.has_metatag?(tag_array, :favgroup)
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_favgroup?
|
|
||||||
is_single_tag? && favgroup_name && favgroup
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def favgroup
|
def favgroup
|
||||||
::FavoriteGroup.find_by_name(favgroup_name)
|
name = Tag.has_metatag?(tag_array, :favgroup)
|
||||||
|
return nil unless is_single_tag? && name.present?
|
||||||
|
|
||||||
|
@favgroup ||= FavoriteGroup.find_by_name(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_explicit?
|
def has_explicit?
|
||||||
|
|||||||
@@ -30,9 +30,9 @@
|
|||||||
<li><%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %></li>
|
<li><%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %></li>
|
||||||
<% elsif @post_set.wiki_page.present? %>
|
<% elsif @post_set.wiki_page.present? %>
|
||||||
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
|
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
|
||||||
<% elsif @post_set.has_pool? %>
|
<% elsif @post_set.pool.present? %>
|
||||||
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
|
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
|
||||||
<% elsif @post_set.has_favgroup? %>
|
<% elsif @post_set.favgroup.present? %>
|
||||||
<li><%= link_to "Favorite Group", favorite_group_path(@post_set.favgroup), :id => "show-excerpt-link" %></li>
|
<li><%= link_to "Favorite Group", favorite_group_path(@post_set.favgroup), :id => "show-excerpt-link" %></li>
|
||||||
<% elsif @post_set.has_blank_wiki? %>
|
<% elsif @post_set.has_blank_wiki? %>
|
||||||
<li><%= link_to "Wiki", new_wiki_page_path(wiki_page: { title: @post_set.tag_string }), id: "show-excerpt-link" %></li>
|
<li><%= link_to "Wiki", new_wiki_page_path(wiki_page: { title: @post_set.tag_string }), id: "show-excerpt-link" %></li>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif post_set.has_pool? %>
|
<% elsif post_set.pool.present? %>
|
||||||
<% post_set.pool.tap do |pool| %>
|
<% post_set.pool.tap do |pool| %>
|
||||||
<h4>
|
<h4>
|
||||||
<%= pool.pretty_category %>:
|
<%= pool.pretty_category %>:
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
<%= link_to "View pool", pool_path(post_set.pool.id) %>
|
<%= link_to "View pool", pool_path(post_set.pool.id) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif post_set.has_favgroup? %>
|
<% elsif post_set.favgroup.present? %>
|
||||||
<h4>
|
<h4>
|
||||||
Favorite Group:
|
Favorite Group:
|
||||||
<%= link_to post_set.favgroup.pretty_name, favorite_group_path(post_set.favgroup) %>
|
<%= link_to post_set.favgroup.pretty_name, favorite_group_path(post_set.favgroup) %>
|
||||||
|
|||||||
Reference in New Issue
Block a user