BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
316cf619
Commit
316cf619
authored
Mar 20, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3247 from Undev/feature/fix_bug_in_team_assigment
Fix bug with downgrade permissions on first project assigment to team
parents
d2ca549f
0f396105
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
user_team_manager.rb
lib/gitlab/user_team_manager.rb
+13
-11
No files found.
lib/gitlab/user_team_manager.rb
View file @
316cf619
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
unless
searched_project
.
present?
unless
searched_project
.
present?
team
.
user_team_project_relationships
.
create
(
project_id:
project
.
id
,
greatest_access:
access
)
team
.
user_team_project_relationships
.
create
(
project_id:
project
.
id
,
greatest_access:
access
)
update_team_users_access_in_project
(
team
,
project
)
update_team_users_access_in_project
(
team
,
project
,
:added
)
end
end
end
end
...
@@ -19,7 +19,7 @@ module Gitlab
...
@@ -19,7 +19,7 @@ module Gitlab
team
.
user_team_project_relationships
.
with_project
(
project
).
destroy_all
team
.
user_team_project_relationships
.
with_project
(
project
).
destroy_all
update_team_users_access_in_project
(
team
,
project
)
update_team_users_access_in_project
(
team
,
project
,
:updated
)
end
end
def
update_team_user_membership
(
team
,
member
,
options
)
def
update_team_user_membership
(
team
,
member
,
options
)
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
project_relation
=
team
.
user_team_project_relationships
.
find_by_project_id
(
project
)
project_relation
=
team
.
user_team_project_relationships
.
find_by_project_id
(
project
)
if
permission
!=
team
.
max_project_access
(
project
)
if
permission
!=
team
.
max_project_access
(
project
)
if
project_relation
.
update_attributes
(
greatest_access:
permission
)
if
project_relation
.
update_attributes
(
greatest_access:
permission
)
update_team_users_access_in_project
(
team
,
project
)
update_team_users_access_in_project
(
team
,
project
,
:updated
)
true
true
else
else
false
false
...
@@ -68,15 +68,15 @@ module Gitlab
...
@@ -68,15 +68,15 @@ module Gitlab
end
end
end
end
def
update_team_users_access_in_project
(
team
,
project
)
def
update_team_users_access_in_project
(
team
,
project
,
action
)
members
=
team
.
members
members
=
team
.
members
members
.
each
do
|
member
|
members
.
each
do
|
member
|
update_team_user_access_in_project
(
team
,
member
,
project
)
update_team_user_access_in_project
(
team
,
member
,
project
,
action
)
end
end
end
end
def
update_team_user_access_in_project
(
team
,
user
,
project
)
def
update_team_user_access_in_project
(
team
,
user
,
project
,
action
)
granted_access
=
max_teams_member_permission_in_project
(
user
,
project
)
granted_access
=
max_teams_member_permission_in_project
(
user
,
project
,
action
)
project_team_user
=
UsersProject
.
find_by_user_id_and_project_id
(
user
.
id
,
project
.
id
)
project_team_user
=
UsersProject
.
find_by_user_id_and_project_id
(
user
.
id
,
project
.
id
)
project_team_user
.
destroy
if
project_team_user
.
present?
project_team_user
.
destroy
if
project_team_user
.
present?
...
@@ -85,12 +85,14 @@ module Gitlab
...
@@ -85,12 +85,14 @@ module Gitlab
project
.
team
<<
[
user
,
granted_access
]
if
granted_access
>
0
project
.
team
<<
[
user
,
granted_access
]
if
granted_access
>
0
end
end
def
max_teams_member_permission_in_project
(
user
,
project
,
teams
=
nil
)
def
max_teams_member_permission_in_project
(
user
,
project
,
action
=
nil
,
teams
=
nil
)
result_access
=
0
result_access
=
0
user_teams
=
project
.
user_teams
.
with_member
(
user
)
teams
||
=
project
.
user_teams
.
with_member
(
user
)
teams
||=
user_teams
if
action
&&
(
action
==
:added
)
&&
(
teams
.
count
==
1
)
result_access
||=
project
.
users_project
.
with_user
(
user
).
first
.
project_access
end
if
teams
.
any?
if
teams
.
any?
teams
.
each
do
|
team
|
teams
.
each
do
|
team
|
...
@@ -113,7 +115,7 @@ module Gitlab
...
@@ -113,7 +115,7 @@ module Gitlab
team
.
user_team_user_relationships
.
create
(
user_id:
user
.
id
,
permission:
access
,
group_admin:
admin
)
team
.
user_team_user_relationships
.
create
(
user_id:
user
.
id
,
permission:
access
,
group_admin:
admin
)
team
.
projects
.
each
do
|
project
|
team
.
projects
.
each
do
|
project
|
update_team_user_access_in_project
(
team
,
user
,
project
)
update_team_user_access_in_project
(
team
,
user
,
project
,
:added
)
end
end
end
end
...
...
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