Code cleanup, reuse the visible scope.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9633 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
61a1fa1b6e
commit
a3c25c18d7
|
@ -52,9 +52,7 @@ class News < ActiveRecord::Base
|
||||||
|
|
||||||
# returns latest news for projects visible by user
|
# returns latest news for projects visible by user
|
||||||
def self.latest(user = User.current, count = 5)
|
def self.latest(user = User.current, count = 5)
|
||||||
includes([:author, :project]).where(
|
visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all
|
||||||
Project.allowed_to_condition(user, :view_news)
|
|
||||||
).order("#{News.table_name}.created_on DESC").limit(count).all
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in New Issue