From 8a3669ba3b560fc4d2d17537e4370686b2918704 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 26 Nov 2014 15:26:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E7=94=A8=E6=AC=A1=E6=95=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=8C=85=E6=8B=AC=E5=A4=9A=E7=BA=A7=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/files_helper.rb | 10 ++++++++-- app/views/files/_course_list.html.erb | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) 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 %>