summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-03 14:38:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-03 14:38:04 +0000
commit1ecef3a95ae0471707ce6490e9c725daabce9d67 (patch)
tree105a30efe4830429418aee5fbed83a6c8b8e4d13 /app/controllers
parentb124501a4e825801024c873304757d3094753f02 (diff)
downloadredmine-1ecef3a95ae0471707ce6490e9c725daabce9d67.tar.gz
redmine-1ecef3a95ae0471707ce6490e9c725daabce9d67.zip
ProjectsController#add_news moved to NewsController#new.
Preview added when adding/editing a news (#590). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1111 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/news_controller.rb29
-rw-r--r--app/controllers/projects_controller.rb13
2 files changed, 27 insertions, 15 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 109afe454..66ed61cf4 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -17,7 +17,9 @@
class NewsController < ApplicationController
layout 'base'
- before_filter :find_project, :authorize, :except => :index
+ before_filter :find_news, :except => [:new, :index, :preview]
+ before_filter :find_project, :only => :new
+ before_filter :authorize, :except => [:index, :preview]
before_filter :find_optional_project, :only => :index
accept_key_auth :index
@@ -36,6 +38,18 @@ class NewsController < ApplicationController
def show
end
+ def new
+ @news = News.new(:project => @project, :author => User.current)
+ if request.post?
+ @news.attributes = params[:news]
+ if @news.save
+ flash[:notice] = l(:notice_successful_create)
+ Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added')
+ redirect_to :controller => 'news', :action => 'index', :project_id => @project
+ end
+ end
+ end
+
def edit
if request.post? and @news.update_attributes(params[:news])
flash[:notice] = l(:notice_successful_update)
@@ -64,14 +78,25 @@ class NewsController < ApplicationController
redirect_to :action => 'index', :project_id => @project
end
+ def preview
+ @text = (params[:news] ? params[:news][:description] : nil)
+ render :partial => 'common/preview'
+ end
+
private
- def find_project
+ def find_news
@news = News.find(params[:id])
@project = @news.project
rescue ActiveRecord::RecordNotFound
render_404
end
+ def find_project
+ @project = Project.find(params[:project_id])
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
def find_optional_project
return true unless params[:project_id]
@project = Project.find(params[:project_id])
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 30e7ef85f..9560a451f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -259,19 +259,6 @@ class ProjectsController < ApplicationController
render :layout => false if request.xhr?
end
- # Add a news to @project
- def add_news
- @news = News.new(:project => @project, :author => User.current)
- if request.post?
- @news.attributes = params[:news]
- if @news.save
- flash[:notice] = l(:notice_successful_create)
- Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added')
- redirect_to :controller => 'news', :action => 'index', :project_id => @project
- end
- end
- end
-
def add_file
if request.post?
@version = @project.versions.find_by_id(params[:version_id])