diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-31 07:16:23 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-31 07:16:23 +0000 |
commit | ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b (patch) | |
tree | 3420c99029f21a21c236c4ff8c0c532dd548401e /app/controllers | |
parent | 48d40a8c8884aefc2287f2030c439578057c9516 (diff) | |
download | redmine-ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b.tar.gz redmine-ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b.zip |
Ability to limit member management to certain roles (#19707).
git-svn-id: http://svn.redmine.org/redmine/trunk@14293 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/members_controller.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index da580fd83..5e5bee822 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -53,14 +53,12 @@ class MembersController < ApplicationController def create members = [] if params[:membership] - if params[:membership][:user_ids] - attrs = params[:membership].dup - user_ids = attrs.delete(:user_ids) - user_ids.each do |user_id| - members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) - end - else - members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id]) + user_ids = Array.wrap(params[:membership][:user_id] || params[:membership][:user_ids]) + user_ids << nil if user_ids.empty? + user_ids.each do |user_id| + member = Member.new(:project => @project, :user_id => user_id) + member.set_editable_role_ids(params[:membership][:role_ids]) + members << member end @project.members << members end @@ -84,7 +82,7 @@ class MembersController < ApplicationController def update if params[:membership] - @member.role_ids = params[:membership][:role_ids] + @member.set_editable_role_ids(params[:membership][:role_ids]) end saved = @member.save respond_to do |format| @@ -101,7 +99,7 @@ class MembersController < ApplicationController end def destroy - if request.delete? && @member.deletable? + if @member.deletable? @member.destroy end respond_to do |format| |