From 8a6a1b94ee83c50b90c716ca6eca77c932c10242 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 29 Mar 2016 20:09:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90=E7=9A=84?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=B8=8E=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 8 ++++++++ app/views/layouts/base_org_newstyle.html.erb | 2 +- app/views/organizations/_org_new_resource.html.erb | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 89a21ba0e..4834cdb9b 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,6 +1,7 @@ # encoding: utf-8 module OrganizationsHelper include ApplicationHelper + include FilesHelper def find_user_not_in_current_org_by_name org @@ -36,4 +37,11 @@ module OrganizationsHelper Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") end + def get_attach_org2(field) + org_attachments = field.attachments + attachments = User.current.admin? ? org_attachments : visable_attachemnts(org_attachments) + return attachments.sort_by{|x| x.created_on}.reverse.first(6) + # Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + end diff --git a/app/views/layouts/base_org_newstyle.html.erb b/app/views/layouts/base_org_newstyle.html.erb index 60653b301..4a9dec200 100644 --- a/app/views/layouts/base_org_newstyle.html.erb +++ b/app/views/layouts/base_org_newstyle.html.erb @@ -233,7 +233,7 @@ <% elsif field.field_type == "Resource" %> - <% org_attachs = get_attach_org(field.id) %> + <% org_attachs = get_attach_org2(field) %>

<%= field.name %>

resource dwonload

diff --git a/app/views/organizations/_org_new_resource.html.erb b/app/views/organizations/_org_new_resource.html.erb index 8ae583722..61e6f44fb 100644 --- a/app/views/organizations/_org_new_resource.html.erb +++ b/app/views/organizations/_org_new_resource.html.erb @@ -6,9 +6,9 @@ <%= link_to truncate(attach.filename,length: 35, omission: '...'), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename+"\n"+attach.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :class => "fl ziyuan-title" %> -

上传时间:<%= format_date attach.created_on %>类型:软件 上传者:尹刚 下载次数:40

+

上传时间:<%= format_date attach.created_on %>类型:<%= attach.tag_list[0] %> 下载次数:<%= attach.downloads%> 引用:<%= attach.quotes.nil? ? 0:attach.quotes %>

- 下载 + <%= link_to "下载", download_named_attachment_path(attach.id, attach.filename), :class => "download-btn fl" %>
<% end %> \ No newline at end of file