diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-21 20:15:24 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-21 20:15:24 +0000 |
commit | c0800b330c858edbb961e71e54771ad30f9fee7b (patch) | |
tree | f5b8f2cb3f28c6093dfa7f70509d166f1b87fb48 /app/controllers/groups_controller.rb | |
parent | a3d4b63261c2e54ace2a0de6cda67cba704bf5d9 (diff) | |
download | redmine-c0800b330c858edbb961e71e54771ad30f9fee7b.tar.gz redmine-c0800b330c858edbb961e71e54771ad30f9fee7b.zip |
Error when adding user to group where he is already assigned (#18665).
git-svn-id: http://svn.redmine.org/redmine/trunk@13785 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/groups_controller.rb')
-rw-r--r-- | app/controllers/groups_controller.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 4a12b9b5b..5d82782ec 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -99,12 +99,18 @@ class GroupsController < ApplicationController end def add_users - @users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a - @group.users << @users if request.post? + @users = User.not_in_group(@group).where(:id => (params[:user_id] || params[:user_ids])).to_a + @group.users << @users respond_to do |format| format.html { redirect_to edit_group_path(@group, :tab => 'users') } format.js - format.api { render_api_ok } + format.api { + if @users.any? + render_api_ok + else + render_api_errors "#{l(:label_user)} #{l('activerecord.errors.messages.invalid')}" + end + } end end |