summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 20:55:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 20:55:02 +0000
commit4f4a019bebd03ffc0109a7004ae7c6bc0e562978 (patch)
tree34611e3afe82a111ad0b0141abc60c3f16a8c74f /app/models/project.rb
parentf5e5822945901bef9302315927d1a31ef8dd0ef4 (diff)
downloadredmine-4f4a019bebd03ffc0109a7004ae7c6bc0e562978.tar.gz
redmine-4f4a019bebd03ffc0109a7004ae7c6bc0e562978.zip
Moved controller code to new method Project#add_default_member.
git-svn-id: http://svn.redmine.org/redmine/trunk@13542 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 27cb4c7a6..1a3534217 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -499,6 +499,15 @@ class Project < ActiveRecord::Base
end
end
+ # Adds user as a project member with the default role
+ # Used for when a non-admin user creates a project
+ def add_default_member(user)
+ role = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
+ member = Member.new(:project => self, :principal => user, :roles => [role])
+ self.members << member
+ member
+ end
+
# Deletes all project's members
def delete_all_members
me, mr = Member.table_name, MemberRole.table_name