diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index bef128e50..f1fc1fc15 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -172,7 +172,7 @@ class AttachmentsController < ApplicationController respond_to do |format| # modify by nwb - if @attachment.container_type == 'Course' + if @attachment.container.is_a?(Course) || @attachment.container.course if @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else @@ -285,6 +285,8 @@ private raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename if @attachment.container_type == 'Course' @course = @attachment.course + elsif @attachment.container.course + @course = @attachment.container.course else unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' @project = @attachment.project diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 8bce84f90..650f65555 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -98,10 +98,12 @@ class NewsController < ApplicationController end def new - @news = News.new(:project => @project, :author => User.current) - @course_tag = @project.project_type - if @course_tag - render :layout => 'base_courses' + #modify by nwb + if @project + @news = News.new(:project => @project, :author => User.current) + elsif @course + @news = News.new(:course => @course, :author => User.current) + render :layout => 'base_courses' end end diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 1318f8afa..8b368ab1e 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -83,6 +83,12 @@ module Redmine end def save_attachments(attachments, author=User.current) + # 清除临时文件 + tempAttach = attachments[:dummy] + if tempAttach && tempAttach[:file] + attachments.delete(:dummy) + end + if attachments.is_a?(Hash) attachments = attachments.stringify_keys attachments = attachments.to_a.sort {|a, b|