@@ -3,7 +3,7 @@ class ContestsController < ApplicationController
|
||||
include ContestantsConcern
|
||||
|
||||
before_action :set_contest, only: %i[ destroy show ]
|
||||
before_action :set_settings_contest, only: %i[ settings_general_edit settings_general_update settings_public_edit settings_public_update settings_onsite_edit settings_onsite_update settings_online_edit settings_online_update settings_categories_edit ]
|
||||
before_action :set_settings_contest, only: %i[ stopwatch stopwatch_continue stopwatch_pause stopwatch_reset stopwatch_start settings_general_edit settings_general_update settings_public_edit settings_public_update settings_onsite_edit settings_onsite_update settings_online_edit settings_online_update settings_categories_edit ]
|
||||
before_action :offline_setup, only: %i[ offline_new offline_create offline_edit offline_update offline_completed ]
|
||||
skip_before_action :require_authentication, only: %i[ scoreboard offline_new offline_create offline_edit offline_update offline_completed ]
|
||||
|
||||
@@ -80,6 +80,47 @@ class ContestsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def stopwatch
|
||||
authorize @contest
|
||||
end
|
||||
|
||||
def stopwatch_continue
|
||||
authorize @contest
|
||||
|
||||
pause_duration = Time.now() - @contest.pause_time
|
||||
@contest.start_time = @contest.start_time + pause_duration
|
||||
@contest.pause_time = nil
|
||||
@contest.save
|
||||
redirect_to "/contests/#{@contest.id}/stopwatch"
|
||||
end
|
||||
|
||||
def stopwatch_pause
|
||||
authorize @contest
|
||||
authorize @contest
|
||||
|
||||
@contest.pause_time = Time.now()
|
||||
@contest.save
|
||||
redirect_to "/contests/#{@contest.id}/stopwatch"
|
||||
end
|
||||
|
||||
def stopwatch_reset
|
||||
authorize @contest
|
||||
|
||||
@contest.start_time = nil
|
||||
@contest.pause_time = nil
|
||||
@contest.save
|
||||
redirect_to "/contests/#{@contest.id}/stopwatch"
|
||||
end
|
||||
|
||||
def stopwatch_start
|
||||
authorize @contest
|
||||
|
||||
@contest.start_time = Time.now()
|
||||
@contest.pause_time = nil
|
||||
@contest.save
|
||||
redirect_to "/contests/#{@contest.id}/stopwatch"
|
||||
end
|
||||
|
||||
def new
|
||||
authorize :contest
|
||||
|
||||
@@ -241,7 +282,7 @@ class ContestsController < ApplicationController
|
||||
end
|
||||
|
||||
def settings_public_params
|
||||
params.expect(contest: [ :public, :ranking_mode ])
|
||||
params.expect(contest: [ :public, :ranking_mode, :show_stopwatch ])
|
||||
end
|
||||
|
||||
def settings_onsite_params
|
||||
|
||||
Reference in New Issue
Block a user