# HG changeset patch # User Jittat Fakcharoenphol # Date 2010-04-15 16:19:06 # Node ID 77a5c6e76df31e93676b5c917a87ed4c59d102e4 # Parent bdf9a550f783ca9b47c20c8e0964b7294823baa9 shows contest start confirmation for indv contest diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -3,11 +3,15 @@ before_filter :authenticate, :except => [:index, :login] before_filter :check_viewability, :except => [:index, :login] - append_before_filter :update_user_start_time, :except => [:index, :login] + append_before_filter :confirm_and_update_start_time, + :except => [:index, + :login, + :confirm_contest_start] # to prevent log in box to be shown when user logged out of the # system only in some tab - prepend_before_filter :reject_announcement_refresh_when_logged_out, :only => [:announcements] + prepend_before_filter :reject_announcement_refresh_when_logged_out, + :only => [:announcements] # COMMENTED OUT: filter in each action instead # before_filter :verify_time_limit, :only => [:submit] @@ -183,6 +187,17 @@ :locals => {:announcement_effect => true}) end + def confirm_contest_start + user = User.find(session[:user_id]) + if request.method == :post + user.update_start_time + redirect_to :action => 'list' + else + @contests = user.contests + @user = user + end + end + protected def prepare_announcements(recent=nil) @@ -334,8 +349,13 @@ } end - def update_user_start_time + def confirm_and_update_start_time user = User.find(session[:user_id]) + if (Configuration.indv_contest_mode? and + Configuration['contest.confirm_indv_contest_start'] and + !user.contest_started?) + redirect_to :action => 'confirm_contest_start' and return + end user.update_start_time end diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -172,7 +172,10 @@ end def contest_started? - if Configuration.contest_mode? + if Configuration.indv_contest_mode? + stat = self.contest_stat + return ((stat != nil) and (stat.started_at != nil)) + elsif Configuration.contest_mode? return true if site==nil return site.started else diff --git a/app/views/main/confirm_contest_start.html.haml b/app/views/main/confirm_contest_start.html.haml new file mode 100644 --- /dev/null +++ b/app/views/main/confirm_contest_start.html.haml @@ -0,0 +1,12 @@ += user_title_bar(@user) + +%center + You will participate in contest: + - @contests.each do |contest| + = contest.title + %br + + The timer will start after you click the start button. + + - form_tag :action => 'confirm_contest_start', :method => 'post' do + = submit_tag 'Start!', :confirm => 'Are you sure?' diff --git a/db/seeds.rb b/db/seeds.rb --- a/db/seeds.rb +++ b/db/seeds.rb @@ -101,6 +101,12 @@ :key => 'system.multicontests', :value_type => 'boolean', :default_value => 'false' + }, + + { + :key => 'contest.confirm_indv_contest_start', + :value_type => 'boolean', + :default_value => 'false' } ]