parent
8f74241eda
commit
a5d829b95e
|
@ -172,7 +172,7 @@ class AttachmentsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
# modify by nwb
|
# modify by nwb
|
||||||
if @attachment.container_type == 'Course'
|
if @attachment.container.is_a?(Course) || @attachment.container.course
|
||||||
if @course.nil?
|
if @course.nil?
|
||||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||||
else
|
else
|
||||||
|
@ -285,6 +285,8 @@ private
|
||||||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
||||||
if @attachment.container_type == 'Course'
|
if @attachment.container_type == 'Course'
|
||||||
@course = @attachment.course
|
@course = @attachment.course
|
||||||
|
elsif @attachment.container.course
|
||||||
|
@course = @attachment.container.course
|
||||||
else
|
else
|
||||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
||||||
@project = @attachment.project
|
@project = @attachment.project
|
||||||
|
|
|
@ -98,9 +98,11 @@ class NewsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
#modify by nwb
|
||||||
|
if @project
|
||||||
@news = News.new(:project => @project, :author => User.current)
|
@news = News.new(:project => @project, :author => User.current)
|
||||||
@course_tag = @project.project_type
|
elsif @course
|
||||||
if @course_tag
|
@news = News.new(:course => @course, :author => User.current)
|
||||||
render :layout => 'base_courses'
|
render :layout => 'base_courses'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,6 +83,12 @@ module Redmine
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_attachments(attachments, author=User.current)
|
def save_attachments(attachments, author=User.current)
|
||||||
|
# 清除临时文件
|
||||||
|
tempAttach = attachments[:dummy]
|
||||||
|
if tempAttach && tempAttach[:file]
|
||||||
|
attachments.delete(:dummy)
|
||||||
|
end
|
||||||
|
|
||||||
if attachments.is_a?(Hash)
|
if attachments.is_a?(Hash)
|
||||||
attachments = attachments.stringify_keys
|
attachments = attachments.stringify_keys
|
||||||
attachments = attachments.to_a.sort {|a, b|
|
attachments = attachments.to_a.sort {|a, b|
|
||||||
|
|
Loading…
Reference in New Issue