summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-05 22:22:51 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-05 22:22:51 +0000
commitad68a82be19f44c8e9ab895075a4e932133ad6ee (patch)
treea8cc406846b7883cda0b4c54a07843395280b694 /app/controllers
parent8509cf80f009436e900294acc821295f21e3b142 (diff)
downloadredmine-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')
-rw-r--r--app/controllers/feeds_controller.rb98
-rw-r--r--app/controllers/news_controller.rb30
-rw-r--r--app/controllers/projects_controller.rb12
3 files changed, 27 insertions, 113 deletions
diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb
deleted file mode 100644
index 0601b8a5e..000000000
--- a/app/controllers/feeds_controller.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-# redMine - project management software
-# Copyright (C) 2006-2007 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-class FeedsController < ApplicationController
- before_filter :find_scope
- session :off
-
- helper :issues
- include IssuesHelper
- helper :custom_fields
- include CustomFieldsHelper
-
- # news feeds
- def news
- News.with_scope(:find => @find_options) do
- @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ]
- end
- headers["Content-Type"] = "application/rss+xml"
- render :action => 'news_atom' if 'atom' == params[:format]
- end
-
- # issue feeds
- def issues
- if @project && params[:query_id]
- query = Query.find(params[:query_id])
- query.executed_by = @user
- # ignore query if it's not valid
- query = nil unless query.valid?
- # override with query conditions
- @find_options[:conditions] = query.statement if query.valid? and @project == query.project
- end
-
- Issue.with_scope(:find => @find_options) do
- @issues = Issue.find :all, :include => [:project, :author, :tracker, :status],
- :order => "#{Issue.table_name}.created_on DESC"
- end
- @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
- headers["Content-Type"] = "application/rss+xml"
- render :action => 'issues_atom' if 'atom' == params[:format]
- end
-
- # issue changes feeds
- def history
- if @project && params[:query_id]
- query = Query.find(params[:query_id])
- query.executed_by = @user
- # ignore query if it's not valid
- query = nil unless query.valid?
- # override with query conditions
- @find_options[:conditions] = query.statement if query.valid? and @project == query.project
- end
-
- Journal.with_scope(:find => @find_options) do
- @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
- :order => "#{Journal.table_name}.created_on DESC"
- end
-
- @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_changes_details))
- headers["Content-Type"] = "application/rss+xml"
- render :action => 'history_atom' if 'atom' == params[:format]
- end
-
-private
- # override for feeds specific authentication
- def check_if_login_required
- @user = User.find_by_rss_key(params[:key])
- render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
- end
-
- def find_scope
- if params[:project_id]
- # project feed
- # check if project is public or if the user is a member
- @project = Project.find(params[:project_id])
- render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project))
- scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
- else
- # global feed
- scope = ["#{Project.table_name}.is_public=?", true]
- end
- @find_options = {:conditions => scope, :limit => Setting.feeds_limit.to_i}
- return true
- end
-end
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
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 4356ec774..8db55ba0d 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -330,21 +330,11 @@ class ProjectsController < ApplicationController
if @news.save
flash[:notice] = l(:notice_successful_create)
Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added')
- redirect_to :action => 'list_news', :id => @project
+ redirect_to :controller => 'news', :action => 'index', :project_id => @project
end
end
end
- # Show news list of @project
- def list_news
- @news_pages, @newss = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :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.name}: #{l(:label_news_plural)}") }
- end
- end
-
def add_file
if request.post?
@version = @project.versions.find_by_id(params[:version_id])