修改主页下载不存在的资源500错误

定义helper方法
This commit is contained in:
huang 2015-05-14 15:37:25 +08:00
parent 97780b7eef
commit 2c568ed370
2 changed files with 14 additions and 5 deletions

View File

@ -593,6 +593,17 @@ module ApplicationHelper
Project.project_tree(projects, &block)
end
# 判断当前用户是否为项目管理员
def is_project_manager?(user_id,project_id)
@result = false
mem = Member.where("user_id = ? and project_id = ?",user_id, project_id)
unless mem.blank?
mem.first.roles.to_s.include?("Manager")
@result = false
end
return @result
end
def principals_check_box_tags(name, principals)
s = ''
principals.each do |principal|

View File

@ -20,16 +20,14 @@
<div class="">
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %>
<!--私有项目资源部能引用,不能设置公开私有-->
<!--公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限-->
<%# if project.is_public? %>
<%#--私有项目资源不能引用,不能设置公开私有--%>
<%#--公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限--%>
<%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% if (Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") || file.author_id == User.current.id) && project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" %>
<% if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id) && project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %>
</span>
<% end %>
<%# end %>
<% end %>
</div>
<div class="cl"></div>