diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 67948a8e1..cab5ada7c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -267,6 +267,8 @@ class ApplicationController < ActionController::Base end when "contest" return true + when "Course" + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) else return true end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a57b5f8a5..b28fda55b 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -76,7 +76,7 @@ class AttachmentsController < ApplicationController candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course course = @attachment.container.course - candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) + candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) elsif @attachment.container.is_a?(Course) course = @attachment.container candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 4f3f401c9..f1f4f06f4 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -72,5 +72,10 @@ module FilesHelper result end - + def get_qute_number attachment + if attachment.copy_from.nil? + return 0 + end + count = Attachment.find_by_sql("select count(*) from attachments where copy_from = #{attachment.copy_from}") + end end \ No newline at end of file diff --git a/app/models/role.rb b/app/models/role.rb index 57fccd53c..f363b52bf 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -161,7 +161,7 @@ class Role < ActiveRecord::Base if action.is_a? Hash allowed_actions.include? "#{action[:controller]}/#{action[:action]}" else - allowed_permissions.include? action + allowed_permissions.include? action end end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index cb776aeb7..51091caae 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,8 +1,8 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, course) %>

共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源

- + <#% end %>--> + 资源列表的多样化排序将在下周上线... +

<% curse_attachments.each do |file| %> @@ -40,7 +41,7 @@

文件大小:<%= number_to_human_size(file.filesize) %>

<%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> -

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

+

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%=get_qute_number file %>

diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb index ef907f40f..58b0edda0 100644 --- a/app/views/files/_show_quote_resource.html.erb +++ b/app/views/files/_show_quote_resource.html.erb @@ -1,8 +1,8 @@
-

将此课件引入我的课程资源库

+
<%= form_tag course_attach_relations_path, method: :post, remote: true,