Skip to content

Commit

Permalink
Make CWS not serve inactive contests in multi-contest mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
vytisb committed Feb 20, 2024
1 parent b413b18 commit 8c7c71d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cms/server/contest/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Copyright © 2015-2016 William Di Luigi <[email protected]>
# Copyright © 2016 Myungwoo Chun <[email protected]>
# Copyright © 2016 Amir Keivan Mohtashami <[email protected]>
# Copyright © 2019 Vytis Banaitis <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -39,7 +40,7 @@
from werkzeug.datastructures import LanguageAccept
from werkzeug.http import parse_accept_header

from cms.db import Contest
from cms.db import get_active_contest_list
from cms.locale import DEFAULT_TRANSLATION, choose_language_code
from cms.server import CommonRequestHandler
from cmscommon.datetime import utc as utc_tzinfo
Expand Down Expand Up @@ -167,7 +168,7 @@ def get(self):
# We need this to be computed for each request because we want to be
# able to import new contests without having to restart CWS.
contest_list = dict()
for contest in self.sql_session.query(Contest).all():
for contest in get_active_contest_list(self.sql_session):
contest_list[contest.name] = contest
self.render("contest_list.html", contest_list=contest_list,
**self.r_params)
2 changes: 2 additions & 0 deletions cms/server/contest/handlers/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Copyright © 2015-2016 William Di Luigi <[email protected]>
# Copyright © 2016 Myungwoo Chun <[email protected]>
# Copyright © 2016 Amir Keivan Mohtashami <[email protected]>
# Copyright © 2019 Vytis Banaitis <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -102,6 +103,7 @@ def choose_contest(self):

# Select the correct contest or return an error
self.contest = self.sql_session.query(Contest)\
.filter(Contest.active.is_(True))\
.filter(Contest.name == contest_name).first()
if self.contest is None:
self.contest = Contest(
Expand Down

0 comments on commit 8c7c71d

Please sign in to comment.