diff --git a/app/controllers/user_admin_controller.rb b/app/controllers/user_admin_controller.rb --- a/app/controllers/user_admin_controller.rb +++ b/app/controllers/user_admin_controller.rb @@ -61,6 +61,7 @@ note = [] error_note = [] + error_msg = nil ok_user = [] lines.split("\n").each do |line| @@ -76,7 +77,7 @@ password = items[2].chomp(" ") else password = random_password - add_random_password=true; + added_random_password=true; end if items.length>= 4 and items[3].chomp(" ").length > 0; @@ -96,11 +97,11 @@ user.remark = remark else user = User.new({:login => login, - :full_name => full_name, - :password => password, - :password_confirmation => password, - :alias => user_alias, - :remark => remark}) + :full_name => full_name, + :password => password, + :password_confirmation => password, + :alias => user_alias, + :remark => remark}) end user.activated = true @@ -112,7 +113,8 @@ end ok_user << user else - error_note << "#{login}" + error_note << "'#{login}'" + error_msg = user.errors.full_messages.to_sentence unless error_msg end end @@ -127,11 +129,13 @@ end # show flash - flash[:success] = 'User(s) ' + note.join(', ') + - ' were successfully created. ' + - '( (+) - created with random passwords.)' + if note.size > 0 + flash[:success] = 'User(s) ' + note.join(', ') + + ' were successfully created. ' + + '( (+) - created with random passwords.)' + end if error_note.size > 0 - flash[:error] = "Following user(s) failed to be created: " + error_note.join(', ') + flash[:error] = "Following user(s) failed to be created: " + error_note.join(', ') + ". The error of the first failed one are: " + error_msg; end redirect_to :action => 'index' end diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -21,11 +21,13 @@ %li If you want to add several users to a group, it may be easier to just re-import those users in = link_to 'New list of users', new_list_user_admin_index_path - page + page. You can also use + = link_to 'Bulk Manage User', bulk_manage_user_admin_index_path + page. =form_tag add_user_group_path(@group), class: 'form-inline' do .form-group =label_tag :user_id, "User" - =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2' + =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2', style: 'width: 10em'; =submit_tag "Add",class: 'btn btn-primary' @@ -52,12 +54,12 @@ %ul %li If you want to add several problem to a group, it may be easier to bulk manage them in the - = link_to 'Bulk Manage', manage_problems_path + = link_to 'Bulk Manage Problems', manage_problems_path page =form_tag add_problem_group_path(@group), class: 'form-inline' do .form-group =label_tag :problem_id, "Problem" - =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2' + =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2', style: 'width: 10em'; =submit_tag "Add",class: 'btn btn-primary'