修改课程资源文件上传功能
This commit is contained in:
parent
cb2c5960fc
commit
149d7ef1f4
|
@ -233,7 +233,13 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
# Authorize the user for the requested action
|
# Authorize the user for the requested action
|
||||||
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
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)
|
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
|
if allowed
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
|
|
@ -63,6 +63,8 @@ class FilesController < ApplicationController
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
#modify by nwb
|
||||||
|
if @project
|
||||||
@addTag=false
|
@addTag=false
|
||||||
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
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])
|
||||||
|
@ -91,6 +93,33 @@ class FilesController < ApplicationController
|
||||||
redirect_to project_files_path(@project)
|
redirect_to project_files_path(@project)
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue