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
dc26a76e
Commit
dc26a76e
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
0c1e4c4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
16 deletions
+22
-16
app/policies/project_policy.rb
app/policies/project_policy.rb
+22
-16
No files found.
app/policies/project_policy.rb
View file @
dc26a76e
...
...
@@ -4,9 +4,6 @@ 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
auditor_access!
if
user
.
auditor?
team_member_owner_access!
if
owner
...
...
@@ -14,11 +11,7 @@ class ProjectPolicy < BasePolicy
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?
...
...
@@ -33,6 +26,11 @@ class ProjectPolicy < BasePolicy
@subject
end
def
owner
@owner
||=
project
.
owner
==
user
||
(
project
.
group
&&
project
.
group
.
has_owner?
(
user
))
end
def
guest_access!
can!
:read_project
can!
:read_board
...
...
@@ -251,14 +249,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?
...
...
@@ -279,6 +269,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