版本库可见权限优化

This commit is contained in:
huang 2016-10-14 09:01:25 +08:00
parent e2ee75d8c1
commit dcbeea6dff
2 changed files with 11 additions and 13 deletions

View File

@ -878,20 +878,18 @@ module ApplicationHelper
Project.project_tree(projects, &block)
end
# 项目版本库可见权限判断
# 条件1、modules中设置不可见或项目没有版本库2、如果项目是私有或者项目版本库隐藏则必须是项目成员才可见
# 项目版本库可见权限判断:
# modules中设置可见
# 版本库存在
# 版本库设置了隐藏则仅仅项目成员可见(hidden_repo:1 隐藏版本库)
# return -> true 可见
def visible_repository?(project)
@result = false
unless project.enabled_modules.where("name = 'repository'").empty? || project.repositories.count == 0
if (project.hidden_repo || !project.is_public?)
if User.current.member_of?(project)
@result = true
end
else
@result = true
end
repository = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first
if project.enabled_modules.where("name = 'repository'").empty? || repository.nil?
result = false
else
result = (project.hidden_repo == 1 && !User.current.member_of?(project)) ? false : true
end
return @result
end
def show_attachment_tip container_id, container_type

View File

@ -56,7 +56,7 @@
<% end %>
<!--版本库-->
<% if visible_repository?(@project) %>
<li id="project_menu_05"><%= link_to l(:project_module_repository),({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).identifier}), :class => "pro_new_proname" %>
<li id="project_menu_05"><%= link_to l(:project_module_repository),({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)}), :class => "pro_new_proname" %>
<% unless @project.project_score.changeset_num == 0 %>
<span class="issues_nav_tag ml5"><%= @project.project_score.changeset_num %></span>
<% end %>