Description:
lists users in each contest. individual user contest management moved to each contest user list page
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r297:2abed488d02c - - 4 files changed: 92 inserted, 19 deleted
@@ -0,0 +1,65 | |||||
|
|
1 | + <h1> | ||
|
|
2 | + List users in <% if @contest %><%= @contest.title %> | ||
|
|
3 | + <% else %>Users not in any contests<% end %> | ||
|
|
4 | + </h1> | ||
|
|
5 | + | ||
|
|
6 | + <div class="submitbox"> | ||
|
|
7 | + <%= link_to '[View all users]', :action => 'list' %> | ||
|
|
8 | + <% if Configuration.multicontests? %> | ||
|
|
9 | + <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> | ||
|
|
10 | + <br/> | ||
|
|
11 | + View users in: | ||
|
|
12 | + <% @contests.each do |contest| %> | ||
|
|
13 | + <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> | ||
|
|
14 | + <% end %> | ||
|
|
15 | + <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> | ||
|
|
16 | + <% end %> | ||
|
|
17 | + </div> | ||
|
|
18 | + | ||
|
|
19 | + <table class="info"> | ||
|
|
20 | + <tr class="info-head"> | ||
|
|
21 | + <th>Login</th> | ||
|
|
22 | + <th>Full name</th> | ||
|
|
23 | + <th>Email</th> | ||
|
|
24 | + <th>Activated?</th> | ||
|
|
25 | + <th></th> | ||
|
|
26 | + <th></th> | ||
|
|
27 | + <th></th> | ||
|
|
28 | + <% if Configuration.multicontests? %> | ||
|
|
29 | + <th>Contests</th> | ||
|
|
30 | + <th>Other enabled contests</th> | ||
|
|
31 | + <% end %> | ||
|
|
32 | + </tr> | ||
|
|
33 | + | ||
|
|
34 | + <% for user in @users %> | ||
|
|
35 | + <tr class="info-<%= cycle("odd","even") %>"> | ||
|
|
36 | + <td><%=h user.login %></td> | ||
|
|
37 | + <td><%=h user.full_name %></td> | ||
|
|
38 | + <td><%=h user.email %></td> | ||
|
|
39 | + <td><%=h user.activated %></td> | ||
|
|
40 | + <td><%= link_to 'Show', :action => 'show', :id => user %></td> | ||
|
|
41 | + <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> | ||
|
|
42 | + <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> | ||
|
|
43 | + <% if Configuration.multicontests? %> | ||
|
|
44 | + <td> | ||
|
|
45 | + <% user.contests.each do |contest| %> | ||
|
|
46 | + <%= contest.name %> [<%= link_to 'x', :action => 'remove_from_contest', :id => user.id, :contest_id => contest.id %>] | ||
|
|
47 | + <% end %> | ||
|
|
48 | + </td> | ||
|
|
49 | + <td> | ||
|
|
50 | + <% @contests.each do |contest| %> | ||
|
|
51 | + <% if not user.contests.all.find {|c| c.id==contest.id } %> | ||
|
|
52 | + <%= contest.name %> [<%= link_to '+', :action => 'add_to_contest', :id => user.id, :contest_id => contest.id %>] | ||
|
|
53 | + <% end %> | ||
|
|
54 | + <% end %> | ||
|
|
55 | + </td> | ||
|
|
56 | + <% end %> | ||
|
|
57 | + </tr> | ||
|
|
58 | + <% end %> | ||
|
|
59 | + </table> | ||
|
|
60 | + | ||
|
|
61 | + | ||
|
|
62 | + <br /> | ||
|
|
63 | + | ||
|
|
64 | + <%= link_to 'New user', :action => 'new' %> | ||
|
|
65 | + <%= link_to 'New list of users', :action => 'new_list' %> |
@@ -18,7 +18,7 | |||||
|
18 | def list |
|
18 | def list |
|
19 | @users = User.find(:all) |
|
19 | @users = User.find(:all) |
|
20 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
20 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
21 |
- @contests = Contest. |
|
21 | + @contests = Contest.enabled |
|
22 | end |
|
22 | end |
|
23 |
|
23 | ||
|
24 | def active |
|
24 | def active |
@@ -156,6 +156,20 | |||||
|
156 |
|
156 | ||
|
157 | # contest management |
|
157 | # contest management |
|
158 |
|
158 | ||
|
|
159 | + def contests | ||
|
|
160 | + if params[:id]!='none' | ||
|
|
161 | + @contest = Contest.find(params[:id]) | ||
|
|
162 | + else | ||
|
|
163 | + @contest = nil | ||
|
|
164 | + end | ||
|
|
165 | + if @contest | ||
|
|
166 | + @users = @contest.users | ||
|
|
167 | + else | ||
|
|
168 | + @users = User.find_users_with_no_contest | ||
|
|
169 | + end | ||
|
|
170 | + @contests = Contest.enabled | ||
|
|
171 | + end | ||
|
|
172 | + | ||
|
159 | def add_to_contest |
|
173 | def add_to_contest |
|
160 | user = User.find(params[:id]) |
|
174 | user = User.find(params[:id]) |
|
161 | contest = Contest.find(params[:contest_id]) |
|
175 | contest = Contest.find(params[:contest_id]) |
@@ -124,6 +124,12 | |||||
|
124 |
|
124 | ||
|
125 | # Contest information |
|
125 | # Contest information |
|
126 |
|
126 | ||
|
|
127 | + def self.find_users_with_no_contest() | ||
|
|
128 | + users = User.find(:all) | ||
|
|
129 | + return users.find_all { |u| u.contests.length == 0 } | ||
|
|
130 | + end | ||
|
|
131 | + | ||
|
|
132 | + | ||
|
127 | def contest_time_left |
|
133 | def contest_time_left |
|
128 | if Configuration.contest_mode? |
|
134 | if Configuration.contest_mode? |
|
129 | return nil if site==nil |
|
135 | return nil if site==nil |
@@ -34,7 +34,13 | |||||
|
34 | <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> |
|
34 | <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> |
|
35 | <%= link_to '[View active users]', :action => 'active' %> |
|
35 | <%= link_to '[View active users]', :action => 'active' %> |
|
36 | <% if Configuration.multicontests? %> |
|
36 | <% if Configuration.multicontests? %> |
|
|
37 | + <br/><b>Multi-contest:</b> | ||
|
37 | <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> |
|
38 | <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> |
|
|
39 | + View users in: | ||
|
|
40 | + <% @contests.each do |contest| %> | ||
|
|
41 | + <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> | ||
|
|
42 | + <% end %> | ||
|
|
43 | + <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> | ||
|
38 | <% end %> |
|
44 | <% end %> |
|
39 | </div> |
|
45 | </div> |
|
40 |
|
46 | ||
@@ -48,10 +54,6 | |||||
|
48 | <th></th> |
|
54 | <th></th> |
|
49 | <th></th> |
|
55 | <th></th> |
|
50 | <th></th> |
|
56 | <th></th> |
|
51 | - <% if Configuration.multicontests? %> |
|
||
|
52 | - <th>Contests</th> |
|
||
|
53 | - <th>Other enabled contests</th> |
|
||
|
54 | - <% end %> |
|
||
|
55 | </tr> |
|
57 | </tr> |
|
56 |
|
58 | ||
|
57 | <% for user in @users %> |
|
59 | <% for user in @users %> |
@@ -64,20 +66,6 | |||||
|
64 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
66 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
65 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
67 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
66 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
68 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
67 | - <% if Configuration.multicontests? %> |
|
||
|
68 | - <td> |
|
||
|
69 | - <% user.contests.each do |contest| %> |
|
||
|
70 | - <%= contest.name %> [<%= link_to 'x', :action => 'remove_from_contest', :id => user.id, :contest_id => contest.id %>] |
|
||
|
71 | - <% end %> |
|
||
|
72 | - </td> |
|
||
|
73 | - <td> |
|
||
|
74 | - <% @contests.each do |contest| %> |
|
||
|
75 | - <% if not user.contests.all.find {|c| c.id==contest.id } %> |
|
||
|
76 | - <%= contest.name %> [<%= link_to '+', :action => 'add_to_contest', :id => user.id, :contest_id => contest.id %>] |
|
||
|
77 | - <% end %> |
|
||
|
78 | - <% end %> |
|
||
|
79 | - </td> |
|
||
|
80 | - <% end %> |
|
||
|
81 | </tr> |
|
69 | </tr> |
|
82 | <% end %> |
|
70 | <% end %> |
|
83 | </table> |
|
71 | </table> |
You need to be logged in to leave comments.
Login now