引用次数统计包括多级引用

This commit is contained in:
z9hang 2014-11-26 15:26:57 +08:00
parent ad2a4487c8
commit 8a3669ba3b
2 changed files with 10 additions and 4 deletions

View File

@ -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
end
count = Attachment.find_by_sql("select count(*) from attachments where copy_from = #{attachment.copy_from}")
else
return result[0].number
end
end
end

View File

@ -41,7 +41,7 @@
<p class="f_l c_grey02 font">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= 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"%>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;<!--|&nbsp;&nbsp;引用<%#=get_qute_number file %>--> </p>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= get_qute_number file %> </p>
</div>
<div class="cl"></div>
<div class="tag_h">