Skip to content
Snippets Groups Projects
Commit 76d4dd1c authored by Martin Mareš's avatar Martin Mareš
Browse files

Zrušena automatická registrace do testovací soutěže

Účastníci se tam brzy budou moci přihlásit sami.
parent 54193190
No related branches found
No related tags found
1 merge request!86Registrace
......@@ -47,7 +47,3 @@ JOB_GC_PERIOD = 60
# Za jak dlouho expiruje dokončená dávka [min]
JOB_EXPIRATION = 5
# Automatické přihlašování účastníků do testovací soutěže
# (kolo aktuální_ročník-T-1, celostátní soutěž)
AUTO_REGISTER_TEST = False
......@@ -21,9 +21,6 @@ import mo.web.util
@app.route('/user/')
def user_index():
pcrs = load_pcrs()
if getattr(config, 'AUTO_REGISTER_TEST', False) and not any(round.category == 'T' for pion, contest, round in pcrs):
if register_to_test():
pcrs = load_pcrs()
return render_template(
'user_index.html',
......@@ -43,36 +40,6 @@ def load_pcrs() -> List[Tuple[db.Participation, db.Contest, db.Round]]:
.all())
def register_to_test() -> bool:
sess = db.get_session()
round = sess.query(db.Round).filter_by(year=mo.current_year, category='T', seq=1, part=0).one_or_none()
if not round:
app.logger.error(f'Nemohu najít kolo {mo.current_year}-T-1')
return False
if round.level != 0:
app.logger.error(f'Kolo {round.round_code_short()} není na celostátní úrovni')
return False
contest = sess.query(db.Contest).filter_by(round=round).limit(1).one_or_none()
if not contest:
app.logger.error(f'Kolo {round.round_code_short()} nemá soutěž')
return False
pion = db.Participation(user=g.user, contest=contest, place=contest.place, state=db.PartState.registered)
sess.add(pion)
sess.flush()
mo.util.log(
type=db.LogType.participant,
what=g.user.user_id,
details={'action': 'add-to-contest', 'new': db.row2dict(pion)},
)
sess.commit()
app.logger.info(f'Účastník #{g.user.user_id} automaticky registrován do soutěže #{contest.contest_id}')
return True
def get_contest(id: int) -> db.Contest:
contest = (db.get_session().query(db.Contest)
.options(joinedload(db.Contest.place),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment