Mercurial > hg > soundsoftware-site
changeset 377:0802551af0a5 live
Merge from branch "feature_126"
author | Chris Cannam |
---|---|
date | Fri, 01 Apr 2011 17:24:48 +0100 |
parents | c2230be27b7e (current diff) dcfde3922ec2 (diff) |
children | 6627ac1de32b |
files | |
diffstat | 5 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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 @@ <div id="news"> <dt> <span class="time"><%= format_time(news.created_on) %></span> -<% if !@project %> +<% project ||= @project %> +<% if !project %> <span class="project"><%= link_to_project(news.project) %></span> <% end %> <span class="headline"><%= link_to h(news.title), news_path(news) %></span>
--- 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 @@ </div> <div class="splitcontentright"> - <% if @news.any? %> + <% if @site_news.any? %> <div class="news box"> - <h3><%=l(:label_news_latest)%></h3> - <%= render :partial => 'news/news', :collection => @news %> - <%= link_to l(:label_news_view_all), :controller => 'news' %> + <h3><%=l(:label_news_site_latest)%></h3> + <%= 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' } %> </div> <% end %> <% if @projects.any? %> @@ -34,6 +35,7 @@ <% end %> <% @project = nil %> </ul> + <%= link_to l(:label_projects_more), :controller => 'projects' %> </div> <% end %> <%= call_hook(:view_welcome_index_right, :projects => @projects) %>
--- 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