Commit 888e493b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Update membership instead of remove/add if it permissions were changed

parent 31fdcac1
...@@ -80,12 +80,18 @@ module Gitlab ...@@ -80,12 +80,18 @@ module Gitlab
def update_team_user_access_in_project(team, user, project, action) def update_team_user_access_in_project(team, user, project, action)
granted_access = max_teams_member_permission_in_project(user, project, action) 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)
if granted_access.zero?
project_team_user.destroy if project_team_user.present? project_team_user.destroy if project_team_user.present?
return
end
# project_team_user.project_access != granted_access if project_team_user.present?
project.team << [user, granted_access] if granted_access > 0 project_team_user.update_attributes(project_access: granted_access)
else
project.team << [user, granted_access]
end
end end
def max_teams_member_permission_in_project(user, project, action = nil, teams = nil) def max_teams_member_permission_in_project(user, project, action = nil, teams = nil)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment