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

CourseModify
nwb 11 years ago
parent 97d920c195
commit 814233d245

@ -102,16 +102,31 @@ class NewsController < ApplicationController
end end
def create def create
@news = News.new(:project => @project, :author => User.current) #modify by nwb
@news.safe_attributes = params[:news] if @project
@news.save_attachments(params[:attachments]) @news = News.new(:project => @project, :author => User.current)
if @news.save @news.safe_attributes = params[:news]
render_attachment_warning_if_needed(@news) @news.save_attachments(params[:attachments])
flash[:notice] = l(:notice_successful_create) if @news.save
redirect_to project_news_index_path(@project) render_attachment_warning_if_needed(@news)
else flash[:notice] = l(:notice_successful_create)
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects' redirect_to project_news_index_path(@project)
render :action => 'new', :layout => layout_file 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
end end

Loading…
Cancel
Save