From 5914fb218ccb716fd054fd6ca578635ad796de2c Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 3 Dec 2013 10:37:19 +0800 Subject: [PATCH] add method to show download link show download count in /project/:id/files --- app/helpers/attachments_helper.rb | 17 +++++++++++++++++ app/views/files/index.html.erb | 5 +++-- app/views/layouts/base_projects.html.erb | 4 ++-- app/views/memos/show.html.erb | 5 +++-- app/views/messages/show.html.erb | 4 +++- config/locales/zh.yml | 2 +- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index f61399c85..0ba0f3554 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -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 diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 536c4f066..40c8e1e51 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -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(:field_downloads), :default_order => 'desc') %> <%= sort_header_tag('description', :caption => l(:field_description)) %> @@ -38,7 +39,7 @@ <%= link_to_attachment file, :download => true, :title => file.description %> <%= format_time(file.created_on) %> <%= number_to_human_size(file.filesize) %> - + <%= file.downloads %> <%= file.description %> <%= link_to(image_tag('delete.png'), attachment_path(file), diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index f7a2976c3..7807be1ae 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -149,10 +149,10 @@ <%=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) %> <%=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) %> diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 81ebd4808..a8084d6d7 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -101,8 +101,9 @@ <%= raw @memo.content %>

<% 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 %>

diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index ddb60e109..dba9b52e7 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -96,7 +96,9 @@
<%= label_tag l(:field_subject) %>: <%=link_to @topic.subject, project_boards_path(@topic.project) %>
-
<%= textilizable(@topic, :content) %>
+
<%= textilizable(@topic, :content) %> + <%= link_to_attachments @topic, :author => false %> +
<%= authoring @topic.created_on, @topic.author %>

diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e6cfac5de..b1c290e72 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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: 讨论区