# HG changeset patch # User jittat # Date 2008-05-09 13:34:46 # Node ID f343b8fb7d21430d37716a3140bd873e3d00a225 # Parent adeb816b0bb6f5c04f298432c6a9cc0f44c61e49 [web] confirm when start contest, downloading task description through apache git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@260 6386c4cd-e34a-4fa8-8920-d93eb39b512e 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 @@ -11,6 +11,16 @@ @user = User.find(session[:user_id]) end + def view + file_name = "#{RAILS_ROOT}/data/tasks/#{params[:file]}" + if !FileTest.exists?(file_name) + redirect_to :action => 'index' and return + end + # ask Apache to send the file + response.headers['X-Sendfile'] = file_name + render :nothing => true + end + protected def check_viewability diff --git a/app/models/configuration.rb b/app/models/configuration.rb --- a/app/models/configuration.rb +++ b/app/models/configuration.rb @@ -55,7 +55,7 @@ return false if mode=='analysis' return true end - + protected def self.read_config @@configurations = {} 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 @@ -17,6 +17,4 @@ Please make sure that the contestants are ready. After the contest is started, it cannot be paused or stopped. %br/ - = submit_tag 'Start the Contest.' - - + = submit_tag 'Start the Contest.', :onclick => "return confirm('Are you sure?');"