Mercurial > hg > soundsoftware-site
diff app/models/news.rb @ 377:0802551af0a5 live
Merge from branch "feature_126"
author | Chris Cannam |
---|---|
date | Fri, 01 Apr 2011 17:24:48 +0100 |
parents | dcfde3922ec2 |
children | 350acce374a2 |
line wrap: on
line diff
--- a/app/models/news.rb Fri Apr 01 12:21:56 2011 +0100 +++ b/app/models/news.rb Fri Apr 01 17:24:48 2011 +0100 @@ -37,4 +37,9 @@ def self.latest(user = User.current, count = 5) find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") end + + # returns latest news for a specific project + def self.latest_for(project, count = 5) + find(:all, :limit => count, :conditions => [ "#{News.table_name}.project_id = #{project.id}", Project.allowed_to_condition(User.current, :view_news) ], :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") + end end