diff --git a/app/helpers/artists_helper.rb b/app/helpers/artists_helper.rb index 861b9280d..d9490d71e 100644 --- a/app/helpers/artists_helper.rb +++ b/app/helpers/artists_helper.rb @@ -1,4 +1,13 @@ module ArtistsHelper + def artist_alias_and_implication_list(artist) + consequent_tag_aliases = TagAlias.where("status in ('active', 'processing') and consequent_name = ?", artist.name) + antecedent_tag_alias = TagAlias.where("status in ('active', 'processing') and antecedent_name = ?", artist.name).first + consequent_tag_implications = TagImplication.where("status in ('active', 'processing') and consequent_name = ?", artist.name) + antecedent_tag_implications = TagImplication.where("status in ('active', 'processing') and antecedent_name = ?", artist.name) + + alias_and_implication_list(antecedent_tag_alias, consequent_tag_aliases, antecedent_tag_implications, consequent_tag_implications) + end + def link_to_artist(name) artist = Artist.find_by_name(name) diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 9065b0fe5..60788bb8d 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -1,4 +1,34 @@ module TagsHelper + def alias_and_implication_list(antecedent_alias, consequent_aliases, antecedent_implications, consequent_implications) + html = "" + + if antecedent_alias + html << "
This tag has been aliased to " + html << link_to(antecedent_alias.consequent_name, show_or_new_wiki_pages_path(:title => antecedent_alias.consequent_name)) + html << ".
" + end + + if consequent_aliases.any? + html << "The following tags are aliased to this tag: " + html << raw(consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) + html << ".
" + end + + if antecedent_implications.any? + html << "This tag implicates " + html << raw(antecedent_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ")) + html << ".
" + end + + if consequent_implications.any? + html << "The following tags implicate this tag: " + html << raw(consequent_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) + html << ".
" + end + + html.html_safe + end + def tag_post_count_style(tag) @highest_post_count ||= Tag.highest_post_count width_percent = Math.log([tag.post_count, 1].max, @highest_post_count) * 100 diff --git a/app/helpers/wiki_pages_helper.rb b/app/helpers/wiki_pages_helper.rb index fb5944fe0..24f1c8149 100644 --- a/app/helpers/wiki_pages_helper.rb +++ b/app/helpers/wiki_pages_helper.rb @@ -5,33 +5,7 @@ module WikiPagesHelper antecedent_implications = wiki_page.presenter.antecedent_tag_implications consequent_implications = wiki_page.presenter.consequent_tag_implications - html = "" - - if antecedent_alias - html << "This tag has been aliased to " - html << link_to(antecedent_alias.consequent_name, show_or_new_wiki_pages_path(:title => antecedent_alias.consequent_name)) - html << ".
" - end - - if consequent_aliases.any? - html << "The following tags are aliased to this tag: " - html << raw(consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) - html << ".
" - end - - if antecedent_implications.any? - html << "This tag implicates " - html << raw(antecedent_implications.map {|x| link_to(x.consequent_name, show_or_new_wiki_pages_path(:title => x.consequent_name))}.join(", ")) - html << ".
" - end - - if consequent_implications.any? - html << "The following tags implicate this tag: " - html << raw(consequent_implications.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", ")) - html << ".
" - end - - html.html_safe + alias_and_implication_list(antecedent_alias, consequent_aliases, antecedent_implications, consequent_implications) end def wiki_page_post_previews(wiki_page) diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 261ebbb6f..8b749e6b8 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -92,7 +92,7 @@ class ForumPost < ActiveRecord::Base end def validate_topic_is_unlocked - return if CurrentUser.user.is_moderator? + return if CurrentUser.is_moderator? return if topic.nil? if topic.is_locked? diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index 9eebb6789..78e7f327e 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -86,7 +86,10 @@ class TagAlias < ActiveRecord::Base clear_all_cache ensure_category_consistency update_posts - update_forum_topic_for_approve if update_topic + admin = CurrentUser.user || User.admins.first + CurrentUser.scoped(admin, "127.0.0.1") do + update_forum_topic_for_approve if update_topic + end update_column(:post_count, consequent_tag.post_count) update_column(:status, "active") rescue Exception => e diff --git a/app/views/posts/partials/index/_excerpt.html.erb b/app/views/posts/partials/index/_excerpt.html.erb index a22968b83..f0724f0e1 100644 --- a/app/views/posts/partials/index/_excerpt.html.erb +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -37,6 +37,8 @@ <% end %> + <%= artist_alias_and_implication_list(post_set.artist) %> +<%= link_to "View artist", artist_path(post_set.artist.id) %>
<% elsif post_set.has_wiki? %>