]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup, reuse the visible scope.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 May 2012 09:54:50 +0000 (09:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 May 2012 09:54:50 +0000 (09:54 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9633 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/news.rb

index 11be6d130a4a6adaa1cb2d3d6b0d679bfa5e57c4..a09f010aa90fe3868a0e74d74f509597adabb4f2 100644 (file)
@@ -52,9 +52,7 @@ class News < ActiveRecord::Base
 
   # returns latest news for projects visible by user
   def self.latest(user = User.current, count = 5)
-    includes([:author, :project]).where(
-        Project.allowed_to_condition(user, :view_news)
-      ).order("#{News.table_name}.created_on DESC").limit(count).all
+    visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
   end
 
   private