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

CourseModify
nwb 11 years ago
parent 97d920c195
commit 814233d245

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

Loading…
Cancel
Save