summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects_controller.rb3
-rw-r--r--app/models/role.rb1
-rw-r--r--app/views/settings/_projects.rhtml3
3 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 5f508cb5f..355e1bd46 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -78,7 +78,8 @@ class ProjectsController < ApplicationController
@project.set_parent!(params[:project]['parent_id']) if User.current.admin? && params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
unless User.current.admin?
- m = Member.new(:user => User.current, :roles => Role.builtin(false).find(:all, :order => 'position', :limit => 1))
+ r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
+ m = Member.new(:user => User.current, :roles => [r])
@project.members << m
end
flash[:notice] = l(:notice_successful_create)
diff --git a/app/models/role.rb b/app/models/role.rb
index a93c4eaca..db5825702 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -20,6 +20,7 @@ class Role < ActiveRecord::Base
BUILTIN_NON_MEMBER = 1
BUILTIN_ANONYMOUS = 2
+ named_scope :givable, { :conditions => "builtin = 0", :order => 'position' }
named_scope :builtin, lambda { |*args|
compare = 'not' if args.first == true
{ :conditions => "#{compare} builtin = 0" }
diff --git a/app/views/settings/_projects.rhtml b/app/views/settings/_projects.rhtml
index 1cd4f6e9b..510807d99 100644
--- a/app/views/settings/_projects.rhtml
+++ b/app/views/settings/_projects.rhtml
@@ -6,6 +6,9 @@
<p><label><%= l(:setting_sequential_project_identifiers) %></label>
<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %></p>
+
+<p><label><%= l(:setting_new_project_user_role_id) %></label>
+<%= select_tag('settings[new_project_user_role_id]', options_for_select([["--- #{l(:actionview_instancetag_blank_option)} ---", '']] + Role.find_all_givable.collect {|r| [r.name, r.id]}, Setting.new_project_user_role_id)) %></p>
</div>
<%= submit_tag l(:button_save) %>