From 740ecc674bf8bed9a5006574482de5b2275b210a Mon Sep 17 00:00:00 2001 From: mlorb Date: Tue, 12 Dec 2017 11:45:19 +0100 Subject: [PATCH] refactor view repositories permission --- app/controllers/repositories_controller.rb | 2 +- app/helpers/permission_helper.rb | 6 +++--- app/permissions/team.rb | 3 ++- app/views/shared/_secondary_navigation.html.erb | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 089236873..63fec7c2b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -299,7 +299,7 @@ class RepositoriesController < ApplicationController end def check_view_all_permissions - render_403 unless can_view_team_repositories(@team) + render_403 unless can_read_team?(@team) end def check_view_permissions diff --git a/app/helpers/permission_helper.rb b/app/helpers/permission_helper.rb index d99612d20..42ed10b0d 100644 --- a/app/helpers/permission_helper.rb +++ b/app/helpers/permission_helper.rb @@ -1042,9 +1042,9 @@ module PermissionHelper # ---- REPOSITORIES PERMISSIONS ---- - def can_view_team_repositories(team) - is_member_of_team(team) - end + # def can_view_team_repositories(team) + # is_member_of_team(team) + # end def can_create_repository(team) is_admin_of_team(team) && diff --git a/app/permissions/team.rb b/app/permissions/team.rb index a74f66a79..8ddd159ab 100644 --- a/app/permissions/team.rb +++ b/app/permissions/team.rb @@ -1,5 +1,6 @@ Canaid::Permissions.register_for(Team) do - # view projects, view protocols, view samples, export samples + # view projects, view protocols + # view samples, export samples, view repositories can :read_team do |user, team| user.is_member_of_team?(team) end diff --git a/app/views/shared/_secondary_navigation.html.erb b/app/views/shared/_secondary_navigation.html.erb index 6761b6eb0..1824d3b92 100644 --- a/app/views/shared/_secondary_navigation.html.erb +++ b/app/views/shared/_secondary_navigation.html.erb @@ -192,7 +192,7 @@ <% end %> - <% if can_view_team_repositories(@my_module.experiment.project.team) && + <% if can_read_team?(@my_module.experiment.project.team) && @my_module.experiment.project.team.repositories.exists? %>
  • "> " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">