Description:
[web] download through apache, sites highlight, logout for site admin
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@263 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r133:d6c2c8c51d7f - - 6 files changed: 27 inserted, 9 deleted
@@ -17,6 +17,11 | |||||
|
17 | redirect_to :action => 'index' |
|
17 | redirect_to :action => 'index' |
|
18 | end |
|
18 | end |
|
19 |
|
19 | ||
|
|
20 | + def logout | ||
|
|
21 | + reset_session | ||
|
|
22 | + redirect_to :controller => 'main', :action => 'login' | ||
|
|
23 | + end | ||
|
|
24 | + | ||
|
20 | protected |
|
25 | protected |
|
21 | def site_admin_authorization |
|
26 | def site_admin_authorization |
|
22 | if session[:site_id]==nil |
|
27 | if session[:site_id]==nil |
@@ -5,7 +5,7 | |||||
|
5 | # GET /sites |
|
5 | # GET /sites |
|
6 | # GET /sites.xml |
|
6 | # GET /sites.xml |
|
7 | def index |
|
7 | def index |
|
8 | - @sites = Site.find(:all) |
|
8 | + @sites = Site.find(:all, :order => 'country_id') |
|
9 |
|
9 | ||
|
10 | respond_to do |format| |
|
10 | respond_to do |format| |
|
11 | format.html # index.html.erb |
|
11 | format.html # index.html.erb |
@@ -14,15 +14,19 | |||||
|
14 | def view |
|
14 | def view |
|
15 | base_filename = File.basename("#{params[:file]}.#{params[:ext]}") |
|
15 | base_filename = File.basename("#{params[:file]}.#{params[:ext]}") |
|
16 | filename = "#{RAILS_ROOT}/data/tasks/#{base_filename}" |
|
16 | filename = "#{RAILS_ROOT}/data/tasks/#{base_filename}" |
|
|
17 | + #filename = "/home/ioi/web_grader/data/tasks/#{base_filename}" | ||
|
|
18 | + #filename = "/home/ioi/web_grader/public/images/rails.png" | ||
|
17 | if !FileTest.exists?(filename) |
|
19 | if !FileTest.exists?(filename) |
|
18 | redirect_to :action => 'index' and return |
|
20 | redirect_to :action => 'index' and return |
|
19 | end |
|
21 | end |
|
20 | - # ask Apache to send the file --- doesn't quite work... |
|
22 | + |
|
21 |
- |
|
23 | + response.headers['Content-Type'] = "application/force-download" |
|
22 |
- |
|
24 | + response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" |
|
23 |
- |
|
25 | + response.headers["X-Sendfile"] = filename |
|
24 |
- |
|
26 | + response.headers['Content-length'] = File.size(filename) |
|
25 |
- |
|
27 | + render :nothing => true |
|
|
28 | + | ||
|
|
29 | + return | ||
|
26 |
|
30 | ||
|
27 | send_file filename, :stream => false, :filename => base_filename |
|
31 | send_file filename, :stream => false, :filename => base_filename |
|
28 | end |
|
32 | end |
@@ -18,3 +18,7 | |||||
|
18 | After the contest is started, it <b>cannot</b> be paused or stopped. |
|
18 | After the contest is started, it <b>cannot</b> be paused or stopped. |
|
19 | %br/ |
|
19 | %br/ |
|
20 | = submit_tag 'Start the Contest.', :onclick => "return confirm('Are you sure?');" |
|
20 | = submit_tag 'Start the Contest.', :onclick => "return confirm('Are you sure?');" |
|
|
21 | + | ||
|
|
22 | + %br/ | ||
|
|
23 | + %br/ | ||
|
|
24 | + = link_to '[log out]', :action => 'logout' |
@@ -26,4 +26,6 | |||||
|
26 | Time left: |
|
26 | Time left: |
|
27 | = "#{Time.at(@site.time_left).gmtime.strftime("%X")}" |
|
27 | = "#{Time.at(@site.time_left).gmtime.strftime("%X")}" |
|
28 |
|
28 | ||
|
29 | - |
|
29 | + %br/ |
|
|
30 | + %br/ | ||
|
|
31 | + = link_to '[log out]', :action => 'logout' |
@@ -8,7 +8,10 | |||||
|
8 | </tr> |
|
8 | </tr> |
|
9 |
|
9 | ||
|
10 | <% for site in @sites %> |
|
10 | <% for site in @sites %> |
|
11 | - <tr> |
|
11 | + <% background = "white" %> |
|
|
12 | + <% background = "grey" if (site.started==true) and (site.finished? == true) %> | ||
|
|
13 | + <% background = "lightgreen" if (site.started==true) and (site.finished? != true) %> | ||
|
|
14 | + <tr style="background: <%= background %>;"> | ||
|
12 | <td><%=h site.name %></td> |
|
15 | <td><%=h site.name %></td> |
|
13 | <td><%=h site.started %></td> |
|
16 | <td><%=h site.started %></td> |
|
14 | <td><%=h site.start_time %></td> |
|
17 | <td><%=h site.start_time %></td> |
You need to be logged in to leave comments.
Login now