|
|
|
@ -102,16 +102,31 @@ class NewsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
@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)
|
|
|
|
|
else
|
|
|
|
|
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
|
|
|
|
|
render :action => 'new', :layout => layout_file
|
|
|
|
|
#modify by nwb
|
|
|
|
|
if @project
|
|
|
|
|
@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)
|
|
|
|
|
else
|
|
|
|
|
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
|
|
|
|
|
render :action => 'new', :layout => layout_file
|
|
|
|
|
end
|
|
|
|
|
elsif @course
|
|
|
|
|
@news = News.new(:course => @course, :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 course_news_index_path(@course)
|
|
|
|
|
else
|
|
|
|
|
layout_file = 'base_courses'
|
|
|
|
|
render :action => 'new', :layout => layout_file
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|