Description:
add adding list of users git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@7 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r4:7ca7b874f4d4 - - 3 files changed: 30 inserted, 0 deleted

@@ -0,0 +1,12
1 + <h1>Adding list of users</h1>
2 +
3 + <div class="usermenu">
4 + <%= link_to 'User admin', :action => 'list' %>
5 + <%= link_to 'Main', :controller => 'main', :action => 'list' %>
6 + </div>
7 +
8 + <% form_tag :action => 'create_from_list' do %>
9 + <%= submit_tag 'create users' %><br/>
10 + List of user information: user_id,name,alias,passwd<br/>
11 + <%= text_area_tag 'user_list', nil, :rows => 50, :cols => 80 %>
12 + <% end %>
@@ -30,12 +30,29
30 30 redirect_to :action => 'list'
31 31 else
32 32 render :action => 'new'
33 33 end
34 34 end
35 35
36 + def create_from_list
37 + lines = params[:user_list]
38 + lines.split("\n").each do |line|
39 + items = line.split
40 + if items.length==5
41 + user = User.new
42 + user.login = items[0]
43 + user.full_name = "#{items[1]} #{items[2]}"
44 + user.alias = items[3]
45 + user.password = items[4]
46 + user.password_confirmation = items[4]
47 + user.save
48 + end
49 + end
50 + redirect_to :action => 'list'
51 + end
52 +
36 53 def edit
37 54 @user = User.find(params[:id])
38 55 end
39 56
40 57 def update
41 58 @user = User.find(params[:id])
@@ -48,6 +48,7
48 48 </table>
49 49
50 50
51 51 <br />
52 52
53 53 <%= link_to 'New user', :action => 'new' %>
54 + <%= link_to 'New list of users', :action => 'new_list' %>
You need to be logged in to leave comments. Login now