From 4006c9243e25d0ded9b23d1f5455ff56740f8377 Mon Sep 17 00:00:00 2001 From: Toks Date: Tue, 9 Apr 2013 14:08:19 -0400 Subject: [PATCH] fixes #1062 --- app/models/post.rb | 4 ++++ app/presenters/post_presenter.rb | 22 ++++++++++++++++++++ app/views/posts/partials/show/_edit.html.erb | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index 6934b5cc7..97bc25141 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -459,6 +459,10 @@ class Post < ActiveRecord::Base typed_tags("artist") end + def general_tags + typed_tags("general") + end + def typed_tags(name) @typed_tags ||= {} @typed_tags[name] ||= begin diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index b540346df..30bf50f38 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -67,6 +67,28 @@ class PostPresenter < Presenter string.join(" ").tr("_", " ") end + def categorized_tag_string + string = [] + + if @post.copyright_tags.any? + string << @post.copyright_tags.join(" ") + end + + if @post.character_tags.any? + string << @post.character_tags.join(" ") + end + + if @post.artist_tags.any? + string << @post.artist_tags.join(" ") + end + + if @post.general_tags.any? + string << @post.general_tags.join(" ") + end + + string.join("\n") + end + def image_html(template) return template.content_tag("p", "The artist requested removal of this image") if @post.is_banned? && !CurrentUser.user.is_privileged? return template.content_tag("p", template.link_to("You need a privileged account to see this image.", template.upgrade_information_users_path)) if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post) diff --git a/app/views/posts/partials/show/_edit.html.erb b/app/views/posts/partials/show/_edit.html.erb index cf6c87ee0..1b19845ac 100644 --- a/app/views/posts/partials/show/_edit.html.erb +++ b/app/views/posts/partials/show/_edit.html.erb @@ -61,7 +61,7 @@
<%= f.label :tag_string, "Tags" %> - <%= f.text_area :tag_string , :size => "50x3", :value => post.tag_string + " " %> + <%= f.text_area :tag_string , :size => "50x3", :value => post.presenter.categorized_tag_string + " " %>
<%= button_tag "Related tags", :id => "related-tags-button", :type => "button" %>