# 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 @@
<%= format_time(news.created_on) %> -<% if !@project %> +<% project ||= @project %> +<% if !project %> <%= link_to_project(news.project) %> <% end %> <%= link_to h(news.title), news_path(news) %> diff -r c2230be27b7e -r 0802551af0a5 app/views/welcome/index.rhtml --- a/app/views/welcome/index.rhtml Fri Apr 01 12:21:56 2011 +0100 +++ b/app/views/welcome/index.rhtml Fri Apr 01 17:24:48 2011 +0100 @@ -13,11 +13,12 @@
- <% if @news.any? %> + <% if @site_news.any? %>
-

<%=l(:label_news_latest)%>

- <%= render :partial => 'news/news', :collection => @news %> - <%= link_to l(:label_news_view_all), :controller => 'news' %> +

<%=l(:label_news_site_latest)%>

+ <%= render :partial => 'news/news', :locals => { :project => @site_project }, :collection => @site_news %> + + <%= link_to l(:label_news_more), { :controller => 'projects', :action => @site_project.identifier, :id => 'news' } %>
<% end %> <% if @projects.any? %> @@ -34,6 +35,7 @@ <% end %> <% @project = nil %> + <%= link_to l(:label_projects_more), :controller => 'projects' %>
<% end %> <%= call_hook(:view_welcome_index_right, :projects => @projects) %> diff -r c2230be27b7e -r 0802551af0a5 config/locales/en.yml --- a/config/locales/en.yml Fri Apr 01 12:21:56 2011 +0100 +++ b/config/locales/en.yml Fri Apr 01 17:24:48 2011 +0100 @@ -464,6 +464,7 @@ other: "{{count}} projects" label_project_all: All Projects label_project_latest: Latest projects + label_projects_more: More projects label_managers: Managed by label_issue: Issue label_issue_new: New issue @@ -560,6 +561,8 @@ label_news_new: Add news label_news_plural: News label_news_latest: Latest news + label_news_site_latest: Site news + label_news_more: More news label_news_view_all: View all news label_news_added: News added label_settings: Settings