forked from cms-dev/cms
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# Copyright © 2010-2012 Matteo Boscariol <[email protected]> | ||
# Copyright © 2013 Bernard Blackham <[email protected]> | ||
# Copyright © 2013-2018 Luca Wehrstedt <[email protected]> | ||
# Copyright © 2014 Vytis Banaitis <[email protected]> | ||
# Copyright © 2016 Myungwoo Chun <[email protected]> | ||
# Copyright © 2016 Masaki Hara <[email protected]> | ||
# Copyright © 2016 Amir Keivan Mohtashami <[email protected]> | ||
|
@@ -75,7 +76,7 @@ | |
# util | ||
"test_db_connection", "get_contest_list", "is_contest_id", | ||
"ask_for_contest", "get_submissions", "get_submission_results", | ||
"get_datasets_to_judge", "enumerate_files" | ||
"get_datasets_to_judge", "enumerate_files", "get_active_contest_list", | ||
] | ||
|
||
|
||
|
@@ -110,7 +111,7 @@ | |
|
||
from .util import test_db_connection, get_contest_list, is_contest_id, \ | ||
ask_for_contest, get_submissions, get_submission_results, \ | ||
get_datasets_to_judge, enumerate_files | ||
get_datasets_to_judge, enumerate_files, get_active_contest_list | ||
|
||
|
||
configure_mappers() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# Copyright © 2010-2012 Matteo Boscariol <[email protected]> | ||
# Copyright © 2012-2018 Luca Wehrstedt <[email protected]> | ||
# Copyright © 2013 Bernard Blackham <[email protected]> | ||
# Copyright © 2014 Vytis Banaitis <[email protected]> | ||
# Copyright © 2016 Myungwoo Chun <[email protected]> | ||
# Copyright © 2016 Amir Keivan Mohtashami <[email protected]> | ||
# Copyright © 2018 William Di Luigi <[email protected]> | ||
|
@@ -258,6 +259,12 @@ class Contest(Base): | |
nullable=False, | ||
default=0) | ||
|
||
# Whether this contest should be handled by CMS services. | ||
active = Column( | ||
Boolean, | ||
nullable=False, | ||
default=False) | ||
|
||
# These one-to-many relationships are the reversed directions of | ||
# the ones defined in the "child" classes using foreign keys. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# Copyright © 2010-2012 Stefano Maggiolo <[email protected]> | ||
# Copyright © 2010-2012 Matteo Boscariol <[email protected]> | ||
# Copyright © 2013-2018 Luca Wehrstedt <[email protected]> | ||
# Copyright © 2014 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 | ||
|
@@ -76,6 +77,25 @@ def get_contest_list(session=None): | |
return session.query(Contest).all() | ||
|
||
|
||
def get_active_contest_list(session=None): | ||
"""Return all active contest objects available on the database. | ||
session (Session): if specified, use such session for connecting | ||
to the database; otherwise, create a temporary one and discard | ||
it after the operation (this means that no further expansion | ||
of lazy properties of the returned Contest objects will be | ||
possible). | ||
return ([Contest]): the list of active contests in the DB. | ||
""" | ||
if session is None: | ||
with SessionGen() as session: | ||
return get_active_contest_list(session) | ||
|
||
return session.query(Contest).filter_by(active=True).all() | ||
|
||
|
||
def is_contest_id(contest_id): | ||
"""Return if there is a contest with the given id in the database. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
# Copyright © 2012-2015 Luca Wehrstedt <[email protected]> | ||
# Copyright © 2014 Artem Iglikov <[email protected]> | ||
# Copyright © 2014 Fabian Gundlach <[email protected]> | ||
# Copyright © 2014 Vytis Banaitis <[email protected]> | ||
# Copyright © 2016 Myungwoo Chun <[email protected]> | ||
# Copyright © 2016 Amir Keivan Mohtashami <[email protected]> | ||
# Copyright © 2018 William Di Luigi <[email protected]> | ||
|
@@ -127,6 +128,8 @@ def post(self, contest_id): | |
self.get_datetime(attrs, "analysis_start") | ||
self.get_datetime(attrs, "analysis_stop") | ||
|
||
self.get_bool(attrs, "active") | ||
|
||
# Update the contest. | ||
contest.set_attrs(attrs) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# Copyright © 2010-2013 Giovanni Mascellani <[email protected]> | ||
# Copyright © 2010-2018 Stefano Maggiolo <[email protected]> | ||
# Copyright © 2010-2012 Matteo Boscariol <[email protected]> | ||
# Copyright © 2014 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 | ||
|
@@ -304,4 +305,6 @@ def update_contest(old_contest, new_contest, parent=None): | |
# must be handled differently. | ||
Contest.tasks: False, | ||
Contest.participations: False, | ||
# Active flag is not managed by the loader. | ||
Contest.active: False, | ||
}, parent=parent) |