1.修改课程通知保存功能

This commit is contained in:
nwb 2014-06-12 09:23:44 +08:00
parent 97d920c195
commit 814233d245
1 changed files with 25 additions and 10 deletions

View File

@ -102,6 +102,8 @@ class NewsController < ApplicationController
end
def create
#modify by nwb
if @project
@news = News.new(:project => @project, :author => User.current)
@news.safe_attributes = params[:news]
@news.save_attachments(params[:attachments])
@ -113,6 +115,19 @@ class NewsController < ApplicationController
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
def edit