summaryrefslogtreecommitdiffstats
path: root/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2010-08-10 22:37:00 +0000
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>2010-08-10 22:37:00 +0000
commit0cfa757db0bed740e6641e245849a72a6f4632a8 (patch)
treea12d7cc68ff9d7f977ad8ea627696bad5a8a5261 /app/controllers/users_controller.rb
parent83e4cf3dd4207faaa393d993a271a52d4413bad3 (diff)
downloadredmine-0cfa757db0bed740e6641e245849a72a6f4632a8.tar.gz
redmine-0cfa757db0bed740e6641e245849a72a6f4632a8.zip
Added a warning when a new user or group membership is invalid. #3834
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3934 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f19cd7831..023352d8a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -123,14 +123,22 @@ class UsersController < ApplicationController
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
@membership.save if request.post?
respond_to do |format|
- format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
- format.js {
- render(:update) {|page|
- page.replace_html "tab-content-memberships", :partial => 'users/memberships'
- page.visual_effect(:highlight, "member-#{@membership.id}")
- }
- }
- end
+ if @membership.valid?
+ format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' }
+ format.js {
+ render(:update) {|page|
+ page.replace_html "tab-content-memberships", :partial => 'users/memberships'
+ page.visual_effect(:highlight, "member-#{@membership.id}")
+ }
+ }
+ else
+ format.js {
+ render(:update) {|page|
+ page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
+ }
+ }
+ end
+ end
end
def destroy_membership