From 00ce5edca0142ab130b9423ef0cf7a99db6cf7d3 Mon Sep 17 00:00:00 2001 From: Angus Ritossa Date: Fri, 12 Jul 2024 11:36:16 +1000 Subject: [PATCH] hide old/upcoming contests --- cms/server/contest/handlers/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cms/server/contest/handlers/base.py b/cms/server/contest/handlers/base.py index 00e24c273..e31ad008b 100644 --- a/cms/server/contest/handlers/base.py +++ b/cms/server/contest/handlers/base.py @@ -31,6 +31,7 @@ import logging import traceback +from datetime import datetime, timedelta try: import tornado4.web as tornado_web @@ -168,6 +169,11 @@ def get(self): # able to import new contests without having to restart CWS. contest_list = dict() for contest in self.sql_session.query(Contest).all(): - contest_list[contest.name] = contest + # We hide contests that ended more than a week ago, or start more than a week from now + today = datetime.now() + seven_days_ago = today - timedelta(days=7) + seven_days_ahead = today + timedelta(days=7) + if contest.start < seven_days_ahead and contest.stop > seven_days_ago: + contest_list[contest.name] = contest self.render("contest_list.html", contest_list=contest_list, **self.r_params)