From a5d829b95ef320184497a65f8dd15a11f86e39ab Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 22 Jul 2014 16:49:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E8=AF=BE=E7=A8=8B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=A8=A1=E5=9D=97=202.=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 +++- app/controllers/news_controller.rb | 10 ++++++---- .../acts_as_attachable/lib/acts_as_attachable.rb | 6 ++++++ 3 files changed, 15 insertions(+), 5 deletions(-) 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|