|
1 | 1 | <% content_for :title, "Problems" %> |
2 | 2 | <% toolbox_push :new, new_problem_path if policy(Problem).create? %> |
3 | 3 |
|
4 | | -<% columns = {:test_status => "", |
5 | | - :linked_name => "Name", |
6 | | - :input => "Input", |
7 | | - :output => "Output", |
8 | | - :memory_limit => "Memory Limt", |
9 | | - :time_limit => "Time Limit", |
10 | | - :linked_owner => "Owner", |
11 | | - :progress_bar => "Progress", |
12 | | - :edit_link => "", |
13 | | - :destroy_link => ""} %> |
14 | 4 | <table class="main_table"> |
15 | 5 | <thead> |
16 | 6 | <tr> |
17 | | - <% @problems_presenter.select_permitted(*columns.keys).each do |key| %> |
18 | | - <th><%= columns[key] %></th> |
19 | | - <% end %> |
| 7 | + <% if policy(Problem.new).inspect? %><th></th><% end %> |
| 8 | + <th>Name</th> |
| 9 | + <th>Input</th> |
| 10 | + <th>Output</th> |
| 11 | + <th>Memory limit</th> |
| 12 | + <th>Time limit</th> |
| 13 | + <th>Owner</th> |
| 14 | + <th>Progress</th> |
| 15 | + <% if policy(Problem.new).update? %><th></th><% end %> |
| 16 | + <% if policy(Problem.new).destroy? %><th></th><% end %> |
20 | 17 | </tr> |
21 | 18 | </thead> |
| 19 | + |
22 | 20 | <tbody> |
23 | | -<% @problems_presenter.each do |problem_presenter| %> |
24 | | - <tr> |
25 | | - <% problem_presenter.presents(*columns.keys).each do |value| %> |
26 | | - <%= content_tag :td, value %> |
| 21 | + <% @problems.each do |problem| %> |
| 22 | + <tr> |
| 23 | + <% if policy(problem).inspect? %> |
| 24 | + <td><%= test_status(problem) %></td> |
| 25 | + <% end %> |
| 26 | + |
| 27 | + <td><%= link_to(problem.name, problem) %></td> |
| 28 | + <td><%= problem.input || "stdin" %></td> |
| 29 | + <td><%= problem.output || "stdout" %></td> |
| 30 | + <td><%= problem.memory_limit %> MB</td> |
| 31 | + <td><%= problem.time_limit %> s</td> |
| 32 | + <td><%= link_to(problem.owner.username, problem.owner) if problem.owner.present? %></td> |
| 33 | + <td><%= progress_bar(problem.score) if problem.score %></td> |
| 34 | + |
| 35 | + <% if policy(problem).update? %> |
| 36 | + <td><%= link_to("Edit", problem_path(problem)) %></td> |
| 37 | + <% end %> |
| 38 | + |
| 39 | + <% if policy(problem).destroy? %> |
| 40 | + <td> |
| 41 | + <%= link_to("Destroy", problem_path(problem), method: :delete, data: { confirm: "Are you sure?" }) %> |
| 42 | + </td> |
| 43 | + <% end %> |
| 44 | + </tr> |
27 | 45 | <% end %> |
28 | | - </tr> |
29 | | -<% end %> |
30 | 46 | </tbody> |
31 | 47 | </table> |
32 | 48 |
|
33 | 49 | <br /> |
34 | | - |
|
0 commit comments