From 6a2e209fe02785af5f1c5265f25c34feb9d8593e Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 24 Aug 2013 13:38:05 -0400 Subject: [PATCH] Hide copy all notes link for posts without notes #1956 --- app/models/post.rb | 6 +++++- app/views/posts/partials/show/_options.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 8b86c0b57..5058e8f3d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -972,6 +972,10 @@ class Post < ActiveRecord::Base last_noted_at.to_i end + def has_notes? + last_noted_at.present? + end + def copy_notes_to(other_post) return if notes.active.length == 0 @@ -1024,7 +1028,7 @@ class Post < ActiveRecord::Base "has_children" => has_children?, "created_at" => created_at.to_formatted_s(:db), "md5" => md5, - "has_notes" => last_noted_at.present?, + "has_notes" => has_notes?, "rating" => rating, "author" => uploader_name, "creator_id" => uploader_id, diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index bb4b2b357..01312fa08 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -9,7 +9,7 @@ <% else %>
  • <%= link_to "Add notes", "#", :id => "translate", :title => "Shortcut is N" %>
  • <% end %> - <% if CurrentUser.is_builder? %> + <% if CurrentUser.is_builder? && post.has_notes? %>
  • <%= link_to "Copy all notes", "#", :id => "copy-notes" %>
  • <% end %>
  • <%= link_to "Find similar", "http://danbooru.iqdb.org/db-search.php?url=http://#{Danbooru.config.hostname}#{post.preview_file_url}" %>