Description:
add more error message to user list upgrade. Fix #9
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r785:2cf37c58fc60 - - 2 files changed: 21 inserted, 15 deleted

@@ -61,6 +61,7
61
61
62 note = []
62 note = []
63 error_note = []
63 error_note = []
64 + error_msg = nil
64 ok_user = []
65 ok_user = []
65
66
66 lines.split("\n").each do |line|
67 lines.split("\n").each do |line|
@@ -76,7 +77,7
76 password = items[2].chomp(" ")
77 password = items[2].chomp(" ")
77 else
78 else
78 password = random_password
79 password = random_password
79 - add_random_password=true;
80 + added_random_password=true;
80 end
81 end
81
82
82 if items.length>= 4 and items[3].chomp(" ").length > 0;
83 if items.length>= 4 and items[3].chomp(" ").length > 0;
@@ -96,11 +97,11
96 user.remark = remark
97 user.remark = remark
97 else
98 else
98 user = User.new({:login => login,
99 user = User.new({:login => login,
99 - :full_name => full_name,
100 + :full_name => full_name,
100 - :password => password,
101 + :password => password,
101 - :password_confirmation => password,
102 + :password_confirmation => password,
102 - :alias => user_alias,
103 + :alias => user_alias,
103 - :remark => remark})
104 + :remark => remark})
104 end
105 end
105 user.activated = true
106 user.activated = true
106
107
@@ -112,7 +113,8
112 end
113 end
113 ok_user << user
114 ok_user << user
114 else
115 else
115 - error_note << "#{login}"
116 + error_note << "'#{login}'"
117 + error_msg = user.errors.full_messages.to_sentence unless error_msg
116 end
118 end
117
119
118 end
120 end
@@ -127,11 +129,13
127 end
129 end
128
130
129 # show flash
131 # show flash
130 - flash[:success] = 'User(s) ' + note.join(', ') +
132 + if note.size > 0
131 - ' were successfully created. ' +
133 + flash[:success] = 'User(s) ' + note.join(', ') +
132 - '( (+) - created with random passwords.)'
134 + ' were successfully created. ' +
135 + '( (+) - created with random passwords.)'
136 + end
133 if error_note.size > 0
137 if error_note.size > 0
134 - flash[:error] = "Following user(s) failed to be created: " + error_note.join(', ')
138 + flash[:error] = "Following user(s) failed to be created: " + error_note.join(', ') + ". The error of the first failed one are: " + error_msg;
135 end
139 end
136 redirect_to :action => 'index'
140 redirect_to :action => 'index'
137 end
141 end
@@ -21,11 +21,13
21 %li
21 %li
22 If you want to add several users to a group, it may be easier to just re-import those users in
22 If you want to add several users to a group, it may be easier to just re-import those users in
23 = link_to 'New list of users', new_list_user_admin_index_path
23 = link_to 'New list of users', new_list_user_admin_index_path
24 - page
24 + page. You can also use
25 + = link_to 'Bulk Manage User', bulk_manage_user_admin_index_path
26 + page.
25 =form_tag add_user_group_path(@group), class: 'form-inline' do
27 =form_tag add_user_group_path(@group), class: 'form-inline' do
26 .form-group
28 .form-group
27 =label_tag :user_id, "User"
29 =label_tag :user_id, "User"
28 - =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2'
30 + =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2', style: 'width: 10em';
29 =submit_tag "Add",class: 'btn btn-primary'
31 =submit_tag "Add",class: 'btn btn-primary'
30
32
31
33
@@ -52,12 +54,12
52 %ul
54 %ul
53 %li
55 %li
54 If you want to add several problem to a group, it may be easier to bulk manage them in the
56 If you want to add several problem to a group, it may be easier to bulk manage them in the
55 - = link_to 'Bulk Manage', manage_problems_path
57 + = link_to 'Bulk Manage Problems', manage_problems_path
56 page
58 page
57 =form_tag add_problem_group_path(@group), class: 'form-inline' do
59 =form_tag add_problem_group_path(@group), class: 'form-inline' do
58 .form-group
60 .form-group
59 =label_tag :problem_id, "Problem"
61 =label_tag :problem_id, "Problem"
60 - =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2'
62 + =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2', style: 'width: 10em';
61 =submit_tag "Add",class: 'btn btn-primary'
63 =submit_tag "Add",class: 'btn btn-primary'
62
64
63
65
You need to be logged in to leave comments. Login now