diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 4b6eccb81..f3be6e904 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -94,9 +94,15 @@ module FilesHelper end def get_qute_number attachment - if attachment.copy_from.nil? + if attachment.copy_from + result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.copy_from}") + else + result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.id}") + end + if result.nil? || result.count <= 0 return 0 + else + return result[0].number 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/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 6e434ed14..93e39f73f 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -41,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 %>
+<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= get_qute_number file %>