From b0e4ed5ab369884b97f362c20821929e9aaa82e3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 May 2016 17:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=88=86=E4=BA=AB=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E8=87=AA=E5=B7=B1=E5=9C=A8=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E8=AF=9D=E5=88=99=E4=B8=8D=E9=9C=80=E8=A6=81=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 15 +++++++++++++++ app/views/users/_resources_list.html.erb | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6e0f70313..8d9c9733e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,6 +49,21 @@ module ApplicationHelper return result end + # 判断某个资源是否可以申请 + def attach_show_allow attach_id + attachment = Attachment.find(attach_id) + case attachment.container_type + when "Project" + User.current.member_of?(attachment.container) ? true : false + when "Course" + User.current.member_of_course?(attachment.container) ? true : false + when "OrgSubfield" + User.current.member_of_org?(attachment.container) ? true : false + when "Principal" + User.current.id == attachment.author_id ? true : false + end + end + # Time 2015-03-24 15:27:29 # Author lizanle # Description 从硬盘上删除对应的资源文件 diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 46a69f985..7d510d977 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -24,9 +24,9 @@ <% end %>
  • - <% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current %> + <% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current && !attach_show_allow(attach) %> <% ah = attach.get_status_by_attach(User.current.id) %> - <% if ah.nil? %> + <% if ah.nil? %> <%= link_to("请求分享", apply_resource_user_path(User.current.id, :attachment_id => attach.id), :class => 'green_btn_share c_white', :remote => true) %> <% elsif ah == 1 %> 等待回复