Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4a924a5e
Commit
4a924a5e
authored
Apr 26, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Rubocop CyclomaticComplexity offense
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
c7df9771
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
18 deletions
+26
-18
app/policies/project_policy.rb
app/policies/project_policy.rb
+26
-18
No files found.
app/policies/project_policy.rb
View file @
4a924a5e
...
...
@@ -2,20 +2,13 @@ class ProjectPolicy < BasePolicy
def
rules
team_access!
(
user
)
owner
=
project
.
owner
==
user
||
(
project
.
group
&&
project
.
group
.
has_owner?
(
user
))
owner_access!
if
user
.
admin?
||
owner
team_member_owner_access!
if
owner
owner_access!
if
user
.
admin?
||
owner?
team_member_owner_access!
if
owner?
if
project
.
public?
||
(
project
.
internal?
&&
!
user
.
external?
)
guest_access!
public_access!
if
project
.
request_access_enabled
&&
!
(
owner
||
user
.
admin?
||
project
.
team
.
member?
(
user
)
||
project_group_member?
(
user
))
can!
:request_access
end
can!
:request_access
if
access_requestable?
end
archived_access!
if
project
.
archived?
...
...
@@ -27,6 +20,13 @@ class ProjectPolicy < BasePolicy
@subject
end
def
owner?
return
@owner
if
defined?
(
@owner
)
@owner
=
project
.
owner
==
user
||
(
project
.
group
&&
project
.
group
.
has_owner?
(
user
))
end
def
guest_access!
can!
:read_project
can!
:read_board
...
...
@@ -226,14 +226,6 @@ class ProjectPolicy < BasePolicy
disabled_features!
end
def
project_group_member?
(
user
)
project
.
group
&&
(
project
.
group
.
members_with_parents
.
exists?
(
user_id:
user
.
id
)
||
project
.
group
.
requesters
.
exists?
(
user_id:
user
.
id
)
)
end
def
block_issues_abilities
unless
project
.
feature_available?
(
:issues
,
user
)
cannot!
:read_issue
if
project
.
default_issues_tracker?
...
...
@@ -254,6 +246,22 @@ class ProjectPolicy < BasePolicy
private
def
project_group_member?
(
user
)
project
.
group
&&
(
project
.
group
.
members_with_parents
.
exists?
(
user_id:
user
.
id
)
||
project
.
group
.
requesters
.
exists?
(
user_id:
user
.
id
)
)
end
def
access_requestable?
project
.
request_access_enabled
&&
!
owner?
&&
!
user
.
admin?
&&
!
project
.
team
.
member?
(
user
)
&&
!
project_group_member?
(
user
)
end
# A base set of abilities for read-only users, which
# is then augmented as necessary for anonymous and other
# read-only users.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment