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:
evazion
2020-01-17 02:13:10 -06:00
parent d16756f186
commit d461bb2ad0
3 changed files with 11 additions and 21 deletions

View File

@@ -41,28 +41,18 @@ module PostSets
tag.artist
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
::Pool.find_by_name(pool_name)
end
name = Tag.has_metatag?(tag_array, :ordpool, :pool)
return nil unless is_single_tag? && name.present?
def favgroup_name
@favgroup_name ||= Tag.has_metatag?(tag_array, :favgroup)
end
def has_favgroup?
is_single_tag? && favgroup_name && favgroup
@pool ||= Pool.find_by_name(name)
end
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
def has_explicit?

View File

@@ -30,9 +30,9 @@
<li><%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %></li>
<% elsif @post_set.wiki_page.present? %>
<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>
<% 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>
<% 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>

View File

@@ -36,7 +36,7 @@
</p>
</div>
<% end %>
<% elsif post_set.has_pool? %>
<% elsif post_set.pool.present? %>
<% post_set.pool.tap do |pool| %>
<h4>
<%= pool.pretty_category %>:
@@ -54,7 +54,7 @@
<%= link_to "View pool", pool_path(post_set.pool.id) %>
</p>
<% end %>
<% elsif post_set.has_favgroup? %>
<% elsif post_set.favgroup.present? %>
<h4>
Favorite Group:
<%= link_to post_set.favgroup.pretty_name, favorite_group_path(post_set.favgroup) %>