Hide copy all notes link for posts without notes

#1956
This commit is contained in:
Toks
2013-08-24 13:38:05 -04:00
parent fd9fb7dc29
commit 6a2e209fe0
2 changed files with 6 additions and 2 deletions

View File

@@ -972,6 +972,10 @@ class Post < ActiveRecord::Base
last_noted_at.to_i last_noted_at.to_i
end end
def has_notes?
last_noted_at.present?
end
def copy_notes_to(other_post) def copy_notes_to(other_post)
return if notes.active.length == 0 return if notes.active.length == 0
@@ -1024,7 +1028,7 @@ class Post < ActiveRecord::Base
"has_children" => has_children?, "has_children" => has_children?,
"created_at" => created_at.to_formatted_s(:db), "created_at" => created_at.to_formatted_s(:db),
"md5" => md5, "md5" => md5,
"has_notes" => last_noted_at.present?, "has_notes" => has_notes?,
"rating" => rating, "rating" => rating,
"author" => uploader_name, "author" => uploader_name,
"creator_id" => uploader_id, "creator_id" => uploader_id,

View File

@@ -9,7 +9,7 @@
<% else %> <% else %>
<li><%= link_to "Add notes", "#", :id => "translate", :title => "Shortcut is N" %></li> <li><%= link_to "Add notes", "#", :id => "translate", :title => "Shortcut is N" %></li>
<% end %> <% end %>
<% if CurrentUser.is_builder? %> <% if CurrentUser.is_builder? && post.has_notes? %>
<li><%= link_to "Copy all notes", "#", :id => "copy-notes" %></li> <li><%= link_to "Copy all notes", "#", :id => "copy-notes" %></li>
<% end %> <% end %>
<li><%= link_to "Find similar", "http://danbooru.iqdb.org/db-search.php?url=http://#{Danbooru.config.hostname}#{post.preview_file_url}" %></li> <li><%= link_to "Find similar", "http://danbooru.iqdb.org/db-search.php?url=http://#{Danbooru.config.hostname}#{post.preview_file_url}" %></li>