|
|
|
@ -62,37 +62,66 @@ class FilesController < ApplicationController
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@addTag=false
|
|
|
|
|
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
|
|
|
|
attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type])
|
|
|
|
|
render_attachment_warning_if_needed(container)
|
|
|
|
|
|
|
|
|
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
|
|
|
|
Mailer.attachments_added(attachments[:files]).deliver
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# TODO: 临时用 nyan
|
|
|
|
|
sort_init 'created_on', 'desc'
|
|
|
|
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
|
|
|
|
'filename' => "#{Attachment.table_name}.filename",
|
|
|
|
|
'size' => "#{Attachment.table_name}.filesize",
|
|
|
|
|
'downloads' => "#{Attachment.table_name}.downloads"
|
|
|
|
|
|
|
|
|
|
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
|
|
|
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
|
|
|
|
|
|
|
|
|
@attachtype = 0
|
|
|
|
|
@contenttype = 0
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
format.html {
|
|
|
|
|
redirect_to project_files_path(@project)
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
#modify by nwb
|
|
|
|
|
if @project
|
|
|
|
|
@addTag=false
|
|
|
|
|
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
|
|
|
|
attachments = Attachment.attach_filesex(container, params[:attachments], params[:attachment_type])
|
|
|
|
|
render_attachment_warning_if_needed(container)
|
|
|
|
|
|
|
|
|
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
|
|
|
|
Mailer.attachments_added(attachments[:files]).deliver
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# TODO: 临时用 nyan
|
|
|
|
|
sort_init 'created_on', 'desc'
|
|
|
|
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
|
|
|
|
'filename' => "#{Attachment.table_name}.filename",
|
|
|
|
|
'size' => "#{Attachment.table_name}.filesize",
|
|
|
|
|
'downloads' => "#{Attachment.table_name}.downloads"
|
|
|
|
|
|
|
|
|
|
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
|
|
|
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
|
|
|
|
|
|
|
|
|
@attachtype = 0
|
|
|
|
|
@contenttype = 0
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
format.html {
|
|
|
|
|
redirect_to project_files_path(@project)
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
elsif @course
|
|
|
|
|
@addTag=false
|
|
|
|
|
attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
|
|
|
|
|
|
|
|
|
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
|
|
|
|
Mailer.attachments_added(attachments[:files]).deliver
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# TODO: 临时用 nyan
|
|
|
|
|
sort_init 'created_on', 'desc'
|
|
|
|
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
|
|
|
|
'filename' => "#{Attachment.table_name}.filename",
|
|
|
|
|
'size' => "#{Attachment.table_name}.filesize",
|
|
|
|
|
'downloads' => "#{Attachment.table_name}.downloads"
|
|
|
|
|
|
|
|
|
|
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
|
|
|
|
|
|
|
|
|
@attachtype = 0
|
|
|
|
|
@contenttype = 0
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
format.html {
|
|
|
|
|
redirect_to course_files_path(@course)
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def tag_saveEx
|
|
|
|
|