# HG changeset patch # User Chris Cannam # Date 1301675088 -3600 # Node ID 0802551af0a58e626bb86a54ef2611213e4afca9 # Parent c2230be27b7e7578d7226a69d976797e29bf961e# Parent dcfde3922ec271759f144518bb2e59f193a0e2eb Merge from branch "feature_126" diff -r c2230be27b7e -r 0802551af0a5 app/controllers/welcome_controller.rb --- a/app/controllers/welcome_controller.rb Fri Apr 01 12:21:56 2011 +0100 +++ b/app/controllers/welcome_controller.rb Fri Apr 01 17:24:48 2011 +0100 @@ -22,7 +22,9 @@ helper :projects def index - @news = News.latest User.current + @site_project = Project.find_by_identifier "soundsoftware-site" + @site_news = [] + @site_news = News.latest_for @site_project if @site_project @projects = Project.latest User.current # tests if user is logged in to generate the tips of the day list diff -r c2230be27b7e -r 0802551af0a5 app/models/news.rb --- 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 diff -r c2230be27b7e -r 0802551af0a5 app/views/news/_news.rhtml --- a/app/views/news/_news.rhtml Fri Apr 01 12:21:56 2011 +0100 +++ b/app/views/news/_news.rhtml Fri Apr 01 17:24:48 2011 +0100 @@ -1,7 +1,8 @@