Commit 0762d07e authored by Robert Speicher's avatar Robert Speicher Committed by Robert Speicher

Merge branch 'fix-project-creation' into 'master'

Creator should be added as a master of the project on creation

Fixes #4222 

This also enable a project creator to add themselves as a master of the
project for existing repositories that were created in the meanwhile
that they don't appear as members.

See merge request !2520
parent 8366dbda
...@@ -91,7 +91,7 @@ class Member < ActiveRecord::Base ...@@ -91,7 +91,7 @@ class Member < ActiveRecord::Base
member.invite_email = user member.invite_email = user
end end
if can_update_member?(current_user, member) if can_update_member?(current_user, member) || project_creator?(member, access_level)
member.created_by ||= current_user member.created_by ||= current_user
member.access_level = access_level member.access_level = access_level
...@@ -107,6 +107,11 @@ class Member < ActiveRecord::Base ...@@ -107,6 +107,11 @@ class Member < ActiveRecord::Base
current_user.can?(:update_group_member, member) || current_user.can?(:update_group_member, member) ||
current_user.can?(:update_project_member, member) current_user.can?(:update_project_member, member)
end end
def project_creator?(member, access_level)
member.new_record? && member.owner? &&
access_level.to_i == ProjectMember::MASTER
end
end end
def invite? def invite?
......
...@@ -95,7 +95,7 @@ module Projects ...@@ -95,7 +95,7 @@ module Projects
system_hook_service.execute_hooks_for(@project, :create) system_hook_service.execute_hooks_for(@project, :create)
unless @project.group unless @project.group
@project.team << [current_user, :master] @project.team << [current_user, :master, current_user]
end end
@project.import_start if @project.import? @project.import_start if @project.import?
......
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