Require contest durations, prefill end times for unfinished puzzles & allow to modify them
This commit is contained in:
@@ -68,11 +68,7 @@ class Completion < ApplicationRecord
|
||||
self.time_seconds = arr[0].to_i
|
||||
end
|
||||
else
|
||||
if self.contest.duration_seconds.present?
|
||||
self.time_seconds = self.contest.duration_seconds
|
||||
else
|
||||
self.time_seconds = 2 * 3600
|
||||
end
|
||||
self.time_seconds = self.contest.duration_seconds
|
||||
self.display_time_from_start = display_time(self.time_seconds)
|
||||
end
|
||||
end
|
||||
@@ -82,9 +78,6 @@ class Completion < ApplicationRecord
|
||||
self.remaining_pieces = nil
|
||||
else
|
||||
self.missing_pieces = nil
|
||||
if !self.offline.present?
|
||||
self.display_time_from_start = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class Contest < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
validates :lang, inclusion: { in: Languages::AVAILABLE_LANGUAGES.map { |lang| lang[:id] } }
|
||||
validates :ranking_mode, inclusion: { in: Ranking::AVAILABLE_RANKING_MODES.map { |lang| lang[:id] } }
|
||||
validates :duration, format: { with: /\A(\d\d:\d\d|\d:\d\d)\z/ }, if: -> { duration.present? }
|
||||
validates :duration, presence: true, format: { with: /\A(\d\d:\d\d|\d:\d\d)\z/ }
|
||||
|
||||
generates_token_for :token
|
||||
|
||||
|
||||
Reference in New Issue
Block a user