Description:
+ new list of user with remark
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r633:49e05926711f - - 1 file changed: 17 inserted, 5 deleted
@@ -53,69 +53,81 | |||||
|
53 | flash[:notice] = 'User was successfully created.' |
|
53 | flash[:notice] = 'User was successfully created.' |
|
54 | redirect_to :action => 'index' |
|
54 | redirect_to :action => 'index' |
|
55 | else |
|
55 | else |
|
56 | render :action => 'new' |
|
56 | render :action => 'new' |
|
57 | end |
|
57 | end |
|
58 | end |
|
58 | end |
|
59 |
|
59 | ||
|
60 | def clear_last_ip |
|
60 | def clear_last_ip |
|
61 | @user = User.find(params[:id]) |
|
61 | @user = User.find(params[:id]) |
|
62 | @user.last_ip = nil |
|
62 | @user.last_ip = nil |
|
63 | @user.save |
|
63 | @user.save |
|
64 | redirect_to action: 'index', page: params[:page] |
|
64 | redirect_to action: 'index', page: params[:page] |
|
65 | end |
|
65 | end |
|
66 |
|
66 | ||
|
67 | def create_from_list |
|
67 | def create_from_list |
|
68 | lines = params[:user_list] |
|
68 | lines = params[:user_list] |
|
69 |
|
69 | ||
|
70 | note = [] |
|
70 | note = [] |
|
71 |
|
71 | ||
|
72 | lines.split("\n").each do |line| |
|
72 | lines.split("\n").each do |line| |
|
73 | items = line.chomp.split(',') |
|
73 | items = line.chomp.split(',') |
|
74 | if items.length>=2 |
|
74 | if items.length>=2 |
|
75 | login = items[0] |
|
75 | login = items[0] |
|
76 | full_name = items[1] |
|
76 | full_name = items[1] |
|
|
77 | + remark ='' | ||
|
|
78 | + user_alias = '' | ||
|
77 |
|
79 | ||
|
78 | added_random_password = false |
|
80 | added_random_password = false |
|
79 | - if items.length>=3 |
|
81 | + if items.length >= 3 and items[2].chomp(" ").length > 0; |
|
80 | password = items[2].chomp(" ") |
|
82 | password = items[2].chomp(" ") |
|
81 | - user_alias = (items.length>=4) ? items[3] : login |
|
||
|
82 | else |
|
83 | else |
|
83 | password = random_password |
|
84 | password = random_password |
|
84 | - user_alias = (items.length>=4) ? items[3] : login |
|
85 | + add_random_password=true; |
|
85 | - added_random_password = true |
|
86 | + end |
|
|
87 | + | ||
|
|
88 | + if items.length>= 4 and items[3].chomp(" ").length > 0; | ||
|
|
89 | + user_alias = items[3].chomp(" ") | ||
|
|
90 | + else | ||
|
|
91 | + user_alias = login | ||
|
|
92 | + end | ||
|
|
93 | + | ||
|
|
94 | + if items.length>=5 | ||
|
|
95 | + remark = items[4].strip; | ||
|
86 | end |
|
96 | end |
|
87 |
|
97 | ||
|
88 | user = User.find_by_login(login) |
|
98 | user = User.find_by_login(login) |
|
89 | if (user) |
|
99 | if (user) |
|
90 | user.full_name = full_name |
|
100 | user.full_name = full_name |
|
91 | user.password = password |
|
101 | user.password = password |
|
|
102 | + user.remark = remark | ||
|
92 | else |
|
103 | else |
|
93 | user = User.new({:login => login, |
|
104 | user = User.new({:login => login, |
|
94 | :full_name => full_name, |
|
105 | :full_name => full_name, |
|
95 | :password => password, |
|
106 | :password => password, |
|
96 | :password_confirmation => password, |
|
107 | :password_confirmation => password, |
|
97 |
- :alias => user_alias |
|
108 | + :alias => user_alias, |
|
|
109 | + :remark => remark}) | ||
|
98 | end |
|
110 | end |
|
99 | user.activated = true |
|
111 | user.activated = true |
|
100 | user.save |
|
112 | user.save |
|
101 |
|
113 | ||
|
102 | if added_random_password |
|
114 | if added_random_password |
|
103 | note << "'#{login}' (+)" |
|
115 | note << "'#{login}' (+)" |
|
104 | else |
|
116 | else |
|
105 | note << login |
|
117 | note << login |
|
106 | end |
|
118 | end |
|
107 | end |
|
119 | end |
|
108 | end |
|
120 | end |
|
109 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
121 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
110 | ' were successfully created. ' + |
|
122 | ' were successfully created. ' + |
|
111 | '( (+) - created with random passwords.)' |
|
123 | '( (+) - created with random passwords.)' |
|
112 | redirect_to :action => 'index' |
|
124 | redirect_to :action => 'index' |
|
113 | end |
|
125 | end |
|
114 |
|
126 | ||
|
115 | def edit |
|
127 | def edit |
|
116 | @user = User.find(params[:id]) |
|
128 | @user = User.find(params[:id]) |
|
117 | end |
|
129 | end |
|
118 |
|
130 | ||
|
119 | def update |
|
131 | def update |
|
120 | @user = User.find(params[:id]) |
|
132 | @user = User.find(params[:id]) |
|
121 | if @user.update_attributes(user_params) |
|
133 | if @user.update_attributes(user_params) |
You need to be logged in to leave comments.
Login now