add method to show download link

show download count in /project/:id/files
This commit is contained in:
yanxd 2013-12-03 10:37:19 +08:00
parent 2b3138f23b
commit 5914fb218c
6 changed files with 29 additions and 8 deletions

View File

@ -53,4 +53,21 @@ module AttachmentsHelper
api.created_on attachment.created_on
end
end
def link_to_memo_attachments(container, options = {})
options.assert_valid_keys(:author, :thumbnails)
if container.attachments.any?
options = {:deletable => deletable?(container), :author => true}.merge(options)
render :partial => 'attachments/links',
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
end
end
private
def deletable? container, user=User.current
User.current.logged? && (container.author == user || user.admin?)
end
end

View File

@ -19,7 +19,8 @@
<%= sort_header_tag('filename', :caption => l(:field_filename)) %>
<%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc') %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %>
<!-- <%= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %> -->
<%#= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc') %>
<th> <%= sort_header_tag('description', :caption => l(:field_description)) %></th>
<th></th>
</tr></thead>
@ -38,7 +39,7 @@
<td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td>
<td class="created_on"><%= format_time(file.created_on) %></td>
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<!-- <td class="downloads"><%= file.downloads %></td> -->
<td class="downloads"><%= file.downloads %></td>
<td class="digest" width="300px"><%= file.description %></td>
<td align="center">
<%= link_to(image_tag('delete.png'), attachment_path(file),

View File

@ -149,10 +149,10 @@
</tr>
<tr>
<td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:project_module_files) ,project_files_path(@project) %>
<%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %>
</td>
<td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %>
<%= link_to l(:project_module_files) ,project_files_path(@project) %>
</td>
</tr>
<tr>

View File

@ -101,8 +101,9 @@
<%= raw @memo.content %>
<p>
<% if @memo.attachments.any?%>
<% options = {:author => true} %>
<%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
<%# options = {:author => true} %>
<%= link_to_memo_attachments @memo, :author => true %>
<%#= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
<% end %>
</p>
</div>

View File

@ -96,7 +96,9 @@
</div>
<div class="memo-section">
<div class="memo-title"><%= label_tag l(:field_subject) %>: <%=link_to @topic.subject, project_boards_path(@topic.project) %></div>
<div class="memo-content"><%= textilizable(@topic, :content) %></div>
<div class="memo-content"><%= textilizable(@topic, :content) %>
<%= link_to_attachments @topic, :author => false %>
</div>
<div class="memo-timestamp"> <%= authoring @topic.created_on, @topic.author %></div>
</div>
<br />

View File

@ -443,7 +443,7 @@ zh:
project_module_time_tracking: 时间跟踪
project_module_news: 新闻
project_module_documents: 文档
project_module_files: 文件
project_module_files: 文件共享
project_module_wiki: Wiki
project_module_repository: 版本库
project_module_boards: 讨论区