diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -17,6 +17,11 @@ redirect_to :action => 'index' end + def logout + reset_session + redirect_to :controller => 'main', :action => 'login' + end + protected def site_admin_authorization if session[:site_id]==nil diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -5,7 +5,7 @@ # GET /sites # GET /sites.xml def index - @sites = Site.find(:all) + @sites = Site.find(:all, :order => 'country_id') respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -14,15 +14,19 @@ def view base_filename = File.basename("#{params[:file]}.#{params[:ext]}") filename = "#{RAILS_ROOT}/data/tasks/#{base_filename}" + #filename = "/home/ioi/web_grader/data/tasks/#{base_filename}" + #filename = "/home/ioi/web_grader/public/images/rails.png" if !FileTest.exists?(filename) redirect_to :action => 'index' and return end - # ask Apache to send the file --- doesn't quite work... - #response.headers['Content-Type'] = "application/force-download" - #response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" - #response.headers['Content-length'] = File.size(filename) - #response.headers['X-Sendfile'] = filename - #render :nothing => true + + response.headers['Content-Type'] = "application/force-download" + response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" + response.headers["X-Sendfile"] = filename + response.headers['Content-length'] = File.size(filename) + render :nothing => true + + return send_file filename, :stream => false, :filename => base_filename end diff --git a/app/views/site/prompt.html.haml b/app/views/site/prompt.html.haml --- a/app/views/site/prompt.html.haml +++ b/app/views/site/prompt.html.haml @@ -18,3 +18,7 @@ After the contest is started, it cannot be paused or stopped. %br/ = submit_tag 'Start the Contest.', :onclick => "return confirm('Are you sure?');" + +%br/ +%br/ += link_to '[log out]', :action => 'logout' diff --git a/app/views/site/started.html.haml b/app/views/site/started.html.haml --- a/app/views/site/started.html.haml +++ b/app/views/site/started.html.haml @@ -26,4 +26,6 @@ Time left: = "#{Time.at(@site.time_left).gmtime.strftime("%X")}" - +%br/ +%br/ += link_to '[log out]', :action => 'logout' diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb --- a/app/views/sites/index.html.erb +++ b/app/views/sites/index.html.erb @@ -8,7 +8,10 @@ <% for site in @sites %> - + <% background = "white" %> + <% background = "grey" if (site.started==true) and (site.finished? == true) %> + <% background = "lightgreen" if (site.started==true) and (site.finished? != true) %> + <%=h site.name %> <%=h site.started %> <%=h site.start_time %>