diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-05 22:22:51 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-05 22:22:51 +0000 |
commit | ad68a82be19f44c8e9ab895075a4e932133ad6ee (patch) | |
tree | a8cc406846b7883cda0b4c54a07843395280b694 /app/controllers/news_controller.rb | |
parent | 8509cf80f009436e900294acc821295f21e3b142 (diff) | |
download | redmine-ad68a82be19f44c8e9ab895075a4e932133ad6ee.tar.gz redmine-ad68a82be19f44c8e9ab895075a4e932133ad6ee.zip |
Moved ProjectsController#list_news to NewsController#index.
Removed FeedsController, issues and news feeds are now handled by issues and news controllers.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@888 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/news_controller.rb')
-rw-r--r-- | app/controllers/news_controller.rb | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 6b143ddeb..c41c5844e 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -17,8 +17,22 @@ class NewsController < ApplicationController layout 'base' - before_filter :find_project, :authorize - + before_filter :find_project, :authorize, :except => :index + before_filter :find_optional_project, :only => :index + accept_key_auth :index + + def index + @news_pages, @newss = paginate :news, + :per_page => 10, + :conditions => (@project ? {:project_id => @project.id} : Project.visible_by(User.current)), + :include => [:author, :project], + :order => "#{News.table_name}.created_on DESC" + respond_to do |format| + format.html { render :layout => false if request.xhr? } + format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } + end + end + def show end @@ -47,7 +61,7 @@ class NewsController < ApplicationController def destroy @news.destroy - redirect_to :controller => 'projects', :action => 'list_news', :id => @project + redirect_to :action => 'index', :project_id => @project end private @@ -56,5 +70,13 @@ private @project = @news.project rescue ActiveRecord::RecordNotFound render_404 - end + end + + def find_optional_project + return true unless params[:project_id] + @project = Project.find(params[:project_id]) + authorize + rescue ActiveRecord::RecordNotFound + render_404 + end end |