Project

General

Profile

Patch #13468 » news.patch

C. X., 2013-03-13 18:52

View differences:

news_controller.rb (working copy)
before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => :index
accept_rss_auth :index
accept_api_auth :index
accept_api_auth :index, :create
helper :watchers
helper :attachments
......
end
def create
Rails.logger.info("PARAMS: #{params.inspect}")
@news = News.new(:project => @project, :author => User.current)
@news.safe_attributes = params[:news]
@news.save_attachments(params[:attachments])
if @news.save
render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create)
redirect_to project_news_index_path(@project)
respond_to do |format|
format.html {
render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create)
redirect_to project_news_index_path(@project)
}
format.api { render_api_ok }
end
else
render :action => 'new'
respond_to do |format|
format.html { render :action => 'new' }
format.api { render_validation_errors(@news) }
end
end
end
(1-1/6)