Description:
add more error message to user list upgrade. Fix #9
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r785:2cf37c58fc60 - - 2 files changed: 13 inserted, 7 deleted
@@ -58,12 +58,13 | |||
|
58 | 58 | |
|
59 | 59 | def create_from_list |
|
60 | 60 | lines = params[:user_list] |
|
61 | 61 | |
|
62 | 62 | note = [] |
|
63 | 63 | error_note = [] |
|
64 | + error_msg = nil | |
|
64 | 65 | ok_user = [] |
|
65 | 66 | |
|
66 | 67 | lines.split("\n").each do |line| |
|
67 | 68 | items = line.chomp.split(',') |
|
68 | 69 | if items.length>=2 |
|
69 | 70 | login = items[0] |
@@ -73,13 +74,13 | |||
|
73 | 74 | |
|
74 | 75 | added_random_password = false |
|
75 | 76 | if items.length >= 3 and items[2].chomp(" ").length > 0; |
|
76 | 77 | password = items[2].chomp(" ") |
|
77 | 78 | else |
|
78 | 79 | password = random_password |
|
79 | - add_random_password=true; | |
|
80 | + added_random_password=true; | |
|
80 | 81 | end |
|
81 | 82 | |
|
82 | 83 | if items.length>= 4 and items[3].chomp(" ").length > 0; |
|
83 | 84 | user_alias = items[3].chomp(" ") |
|
84 | 85 | else |
|
85 | 86 | user_alias = login |
@@ -109,13 +110,14 | |||
|
109 | 110 | note << "'#{login}' (+)" |
|
110 | 111 | else |
|
111 | 112 | note << login |
|
112 | 113 | end |
|
113 | 114 | ok_user << user |
|
114 | 115 | else |
|
115 | - error_note << "#{login}" | |
|
116 | + error_note << "'#{login}'" | |
|
117 | + error_msg = user.errors.full_messages.to_sentence unless error_msg | |
|
116 | 118 | end |
|
117 | 119 | |
|
118 | 120 | end |
|
119 | 121 | end |
|
120 | 122 | |
|
121 | 123 | #add to group |
@@ -124,17 +126,19 | |||
|
124 | 126 | if group |
|
125 | 127 | group.users << ok_user |
|
126 | 128 | end |
|
127 | 129 | end |
|
128 | 130 | |
|
129 | 131 | # show flash |
|
132 | + if note.size > 0 | |
|
130 | 133 | flash[:success] = 'User(s) ' + note.join(', ') + |
|
131 | 134 | ' were successfully created. ' + |
|
132 | 135 | '( (+) - created with random passwords.)' |
|
136 | + end | |
|
133 | 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 | 139 | end |
|
136 | 140 | redirect_to :action => 'index' |
|
137 | 141 | end |
|
138 | 142 | |
|
139 | 143 | def edit |
|
140 | 144 | @user = User.find(params[:id]) |
@@ -18,17 +18,19 | |||
|
18 | 18 | .panel-title Users in this group |
|
19 | 19 | .panel-body |
|
20 | 20 | %ul |
|
21 | 21 | %li |
|
22 | 22 | If you want to add several users to a group, it may be easier to just re-import those users in |
|
23 | 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 | 27 | =form_tag add_user_group_path(@group), class: 'form-inline' do |
|
26 | 28 | .form-group |
|
27 | 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 | 31 | =submit_tag "Add",class: 'btn btn-primary' |
|
30 | 32 | |
|
31 | 33 | |
|
32 | 34 | %table.table.table-hover |
|
33 | 35 | %thead |
|
34 | 36 | %tr |
@@ -49,18 +51,18 | |||
|
49 | 51 | .panel-heading |
|
50 | 52 | .panel-title Problems |
|
51 | 53 | .panel-body |
|
52 | 54 | %ul |
|
53 | 55 | %li |
|
54 | 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 | 58 | page |
|
57 | 59 | =form_tag add_problem_group_path(@group), class: 'form-inline' do |
|
58 | 60 | .form-group |
|
59 | 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 | 63 | =submit_tag "Add",class: 'btn btn-primary' |
|
62 | 64 | |
|
63 | 65 | |
|
64 | 66 | %table.table.table-hover |
|
65 | 67 | %thead |
|
66 | 68 | %tr |
You need to be logged in to leave comments.
Login now