diff options
-rw-r--r-- | app/models/comment.rb | 2 | ||||
-rw-r--r-- | app/models/info_request.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/user/_user_listing_single.html.erb | 2 | ||||
-rw-r--r-- | app/views/user/show.html.erb | 4 |
5 files changed, 11 insertions, 5 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/info_request.rb b/app/models/info_request.rb index bdc9ec040..3ce0e3cd2 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -200,7 +200,9 @@ class InfoRequest < ActiveRecord::Base OLD_AGE_IN_DAYS = 21.days def visible_comments - self.comments.find(:all, :conditions => 'visible') + warn %q([DEPRECATION] InfoRequest#visible_comments will be replaced with + InfoRequest#comments.visible as of 0.23).squish + comments.visible end # If the URL name has changed, then all request: queries will break unless diff --git a/app/models/user.rb b/app/models/user.rb index bb40dbc26..d50000aba 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -198,7 +198,9 @@ class User < ActiveRecord::Base end def visible_comments - comments.find(:all, :conditions => 'visible') + warn %q([DEPRECATION] User#visible_comments will be replaced with + User#comments.visible as of 0.23).squish + comments.visible end # Don't display any leading/trailing spaces 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 %> |