修改课程资源文件上传功能
This commit is contained in:
parent
cb2c5960fc
commit
149d7ef1f4
|
@ -233,7 +233,13 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# Authorize the user for the requested action
|
||||
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
||||
#modify by NWB
|
||||
if @project
|
||||
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
||||
elsif @course
|
||||
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global)
|
||||
end
|
||||
|
||||
if allowed
|
||||
true
|
||||
else
|
||||
|
|
|
@ -63,9 +63,11 @@ class FilesController < ApplicationController
|
|||
format.js
|
||||
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])
|
||||
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')
|
||||
|
@ -79,7 +81,7 @@ class FilesController < ApplicationController
|
|||
'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.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
|
||||
|
@ -91,6 +93,33 @@ class FilesController < ApplicationController
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue