aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/comment.rb2
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/user/_user_listing_single.html.erb2
-rw-r--r--app/views/user/show.html.erb4
4 files changed, 5 insertions, 7 deletions
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 772bb3eda..59f91ffb7 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -33,6 +33,8 @@ class Comment < ActiveRecord::Base
validate :check_body_has_content,
:check_body_uses_mixed_capitals
+ scope :visible, where(:visible => true)
+
after_save :event_xapian_update
# When posting a new comment, use this to check user hasn't double
diff --git a/app/models/user.rb b/app/models/user.rb
index bb40dbc26..df12b823b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -197,10 +197,6 @@ class User < ActiveRecord::Base
(locale || I18n.locale).to_s
end
- def visible_comments
- comments.find(:all, :conditions => 'visible')
- end
-
# Don't display any leading/trailing spaces
# TODO: we have strip_attributes! now, so perhaps this can be removed (might
# be still needed for existing cases)
diff --git a/app/views/user/_user_listing_single.html.erb b/app/views/user/_user_listing_single.html.erb
index 3cb0d283f..03ac7347b 100644
--- a/app/views/user/_user_listing_single.html.erb
+++ b/app/views/user/_user_listing_single.html.erb
@@ -17,7 +17,7 @@ end %>
<span class="bottomline">
<%= pluralize(display_user.info_requests.size, "request") %> <%= _('made.')%>
- <%= pluralize(display_user.visible_comments.size, "annotation") %> <%= _('made.')%>
+ <%= pluralize(display_user.comments.visible.size, "annotation") %> <%= _('made.')%>
<%= _('Joined in')%> <%= display_user.created_at.year %>.
</span>
diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb
index 78b513d6a..a67663389 100644
--- a/app/views/user/show.html.erb
+++ b/app/views/user/show.html.erb
@@ -173,7 +173,7 @@
<% end %>
<% else %>
<h2 id="annotations">
- <%= @is_you ? n_('Your {{count}} annotation', 'Your {{count}} annotations', @display_user.visible_comments.size, :count => @display_user.visible_comments.size) : n_("This person's {{count}} annotation", "This person's {{count}} annotations", @display_user.visible_comments.size, :count => @display_user.visible_comments.size) %>
+ <%= @is_you ? n_('Your {{count}} annotation', 'Your {{count}} annotations', @display_user.comments.visible.size, :count => @display_user.comments.visible.size) : n_("This person's {{count}} annotation", "This person's {{count}} annotations", @display_user.comments.visible.size, :count => @display_user.comments.visible.size) %>
<!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
<%= @page_desc %>
</h2>
@@ -182,7 +182,7 @@
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model] } %>
<% end %>
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.comments.visible.size) %>
<% end %>
<% end %>