Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions cms/db/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ class Contest(Base):
Unicode,
nullable=True)

# Max contest time for each user in seconds.
per_user_time: timedelta | None = Column(
Interval,
CheckConstraint("per_user_time >= '0 seconds'"),
nullable=True)

# Maximum number of submissions or user_tests allowed for each user
# during the whole contest or None to not enforce this limitation.
max_submission_number: int | None = Column(
Expand Down
6 changes: 3 additions & 3 deletions cms/server/contest/submission/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ def is_last_minutes(timestamp: datetime, participation: Participation):
or participation.contest.min_submission_interval_grace_period is None:
return False

if participation.contest.per_user_time is None:
end_time = participation.contest.stop
if participation.group.per_user_time is None:
end_time = participation.group.stop
else:
end_time = participation.starting_time + participation.contest.per_user_time
end_time = participation.starting_time + participation.group.per_user_time

end_time += participation.delay_time + participation.extra_time
time_left = end_time - timestamp
Expand Down
2 changes: 1 addition & 1 deletion cms/server/contest/templates/contest_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h3>{% trans %}Choose a contest{% endtrans %}</h3>
<ul class="nav nav-list">
{% for c_name, c_iter in contest_list|dictsort(by="key") %}
<li>
<a {% if c_iter.stop < now %} style="color: #adadad" {% endif %} href="{{ url(c_iter.name) }}">{{ c_iter.description }}</a>
<a {% if c_iter.main_group.stop < now %} style="color: #adadad" {% endif %} href="{{ url(c_iter.name) }}">{{ c_iter.description }}</a>
</li>
{% endfor %}
</ul>
Expand Down
3 changes: 3 additions & 0 deletions cmscontrib/updaters/update_from_1.5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,7 @@ ALTER TABLE contests DROP COLUMN analysis_enabled;
ALTER TABLE contests DROP COLUMN analysis_start;
ALTER TABLE contests DROP COLUMN analysis_stop;

-- https://github.com/cms-dev/cms/pull/1672
ALTER TABLE contests DROP COLUMN per_user_time;

COMMIT;
18 changes: 9 additions & 9 deletions cmstestsuite/unit_tests/server/contest/submission/check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,19 @@ def test_no_per_user_time_and_not_last_minutes(self):
is_last_minutes(self.timestamp - timedelta(minutes=15), self.participation))

def test_per_user_time_and_last_minutes(self):
self.participation.contest.per_user_time = timedelta(hours=5)
self.participation.contest.start = self.timestamp - timedelta(hours=10)
self.participation.contest.stop = self.timestamp
self.participation.group.per_user_time = timedelta(hours=5)
self.participation.group.start = self.timestamp - timedelta(hours=10)
self.participation.group.stop = self.timestamp
self.participation.starting_time = self.timestamp - timedelta(hours=5)
self.contest.min_submission_interval_grace_period = timedelta(minutes=15)

self.assertTrue(
is_last_minutes(self.timestamp - timedelta(minutes=15), self.participation))

def test_per_user_time_and_not_last_minutes(self):
self.participation.contest.per_user_time = timedelta(hours=5)
self.participation.contest.start = self.timestamp - timedelta(hours=10)
self.participation.contest.stop = self.timestamp
self.participation.group.per_user_time = timedelta(hours=5)
self.participation.group.start = self.timestamp - timedelta(hours=10)
self.participation.group.stop = self.timestamp
self.participation.starting_time = self.timestamp - timedelta(hours=5)
self.contest.min_submission_interval_grace_period = timedelta(minutes=10)

Expand Down Expand Up @@ -474,9 +474,9 @@ def test_unrestricted_participation(self):
self.assertFalse(is_last_minutes(self.timestamp, self.participation))

def setup_contest_with_no_user_time(self):
self.participation.contest.per_user_time = None
self.participation.contest.start = self.timestamp - timedelta(hours=5)
self.participation.contest.stop = self.timestamp
self.participation.group.per_user_time = None
self.participation.group.start = self.timestamp - timedelta(hours=5)
self.participation.group.stop = self.timestamp


if __name__ == "__main__":
Expand Down
Loading