Description:
confusing merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r483:7cf62e1e74ba - - 1 file changed: 0 inserted, 1 deleted
@@ -1,101 +1,100 | |||
|
1 | 1 | require 'csv' |
|
2 | 2 | |
|
3 | 3 | class UserAdminController < ApplicationController |
|
4 | 4 | |
|
5 | - | |
|
6 | 5 | include MailHelperMethods |
|
7 | 6 | |
|
8 | 7 | before_filter :admin_authorization |
|
9 | 8 | |
|
10 | 9 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
11 | 10 | verify :method => :post, :only => [ :destroy, |
|
12 | 11 | :create, :create_from_list, |
|
13 | 12 | :update, |
|
14 | 13 | :manage_contest, |
|
15 | 14 | :bulk_mail |
|
16 | 15 | ], |
|
17 | 16 | :redirect_to => { :action => :list } |
|
18 | 17 | |
|
19 | 18 | def index |
|
20 | 19 | list |
|
21 | 20 | render :action => 'list' |
|
22 | 21 | end |
|
23 | 22 | |
|
24 | 23 | def list |
|
25 | 24 | @user_count = User.count |
|
26 | 25 | if params[:page] == 'all' |
|
27 | 26 | @users = User.all |
|
28 | 27 | @paginated = false |
|
29 | 28 | else |
|
30 | 29 | @users = User.paginate :page => params[:page] |
|
31 | 30 | @paginated = true |
|
32 | 31 | end |
|
33 | 32 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
34 | 33 | @contests = Contest.enabled |
|
35 | 34 | end |
|
36 | 35 | |
|
37 | 36 | def active |
|
38 | 37 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
39 | 38 | @users = [] |
|
40 | 39 | sessions.each do |session| |
|
41 | 40 | if session.data[:user_id] |
|
42 | 41 | @users << User.find(session.data[:user_id]) |
|
43 | 42 | end |
|
44 | 43 | end |
|
45 | 44 | end |
|
46 | 45 | |
|
47 | 46 | def show |
|
48 | 47 | @user = User.find(params[:id]) |
|
49 | 48 | end |
|
50 | 49 | |
|
51 | 50 | def new |
|
52 | 51 | @user = User.new |
|
53 | 52 | end |
|
54 | 53 | |
|
55 | 54 | def create |
|
56 | 55 | @user = User.new(params[:user]) |
|
57 | 56 | @user.activated = true |
|
58 | 57 | if @user.save |
|
59 | 58 | flash[:notice] = 'User was successfully created.' |
|
60 | 59 | redirect_to :action => 'list' |
|
61 | 60 | else |
|
62 | 61 | render :action => 'new' |
|
63 | 62 | end |
|
64 | 63 | end |
|
65 | 64 | |
|
66 | 65 | def create_from_list |
|
67 | 66 | lines = params[:user_list] |
|
68 | 67 | |
|
69 | 68 | note = [] |
|
70 | 69 | |
|
71 | 70 | lines.split("\n").each do |line| |
|
72 | 71 | items = line.chomp.split(',') |
|
73 | 72 | if items.length>=2 |
|
74 | 73 | login = items[0] |
|
75 | 74 | full_name = items[1] |
|
76 | 75 | |
|
77 | 76 | added_random_password = false |
|
78 | 77 | if items.length>=3 |
|
79 | 78 | password = items[2].chomp(" ") |
|
80 | 79 | user_alias = (items.length>=4) ? items[3] : login |
|
81 | 80 | else |
|
82 | 81 | password = random_password |
|
83 | 82 | user_alias = (items.length>=4) ? items[3] : login |
|
84 | 83 | added_random_password = true |
|
85 | 84 | end |
|
86 | 85 | |
|
87 | 86 | user = User.find_by_login(login) |
|
88 | 87 | if (user) |
|
89 | 88 | user.full_name = full_name |
|
90 | 89 | user.password = password |
|
91 | 90 | else |
|
92 | 91 | user = User.new({:login => login, |
|
93 | 92 | :full_name => full_name, |
|
94 | 93 | :password => password, |
|
95 | 94 | :password_confirmation => password, |
|
96 | 95 | :alias => user_alias}) |
|
97 | 96 | end |
|
98 | 97 | user.activated = true |
|
99 | 98 | user.save |
|
100 | 99 | |
|
101 | 100 | if added_random_password |
You need to be logged in to leave comments.
Login now