From d4b12afc0c06bfc2a43ccedad47851000d40f4c6 Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Sat, 31 Jul 2021 20:42:37 +0200
Subject: [PATCH] Fields: ParticipantsActionForm
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Oblast se bude zadávat pomocí mo_fields.
---
mo/web/org_contest.py | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/mo/web/org_contest.py b/mo/web/org_contest.py
index d6f272b5..37e380b0 100644
--- a/mo/web/org_contest.py
+++ b/mo/web/org_contest.py
@@ -90,12 +90,12 @@ class ParticipantsActionForm(FlaskForm):
participation_state = wtforms.SelectField('Stav účasti', choices=db.PartState.choices(), coerce=db.PartState.coerce)
set_participation_state = wtforms.SubmitField("Nastavit stav účasti")
- participation_place = wtforms.StringField(
+ participation_place = mo_fields.Place(
'Soutěžní místo', description='Zadejte kód místa'
)
set_participation_place = wtforms.SubmitField("Nastavit soutěžní místo")
- contest_place = wtforms.StringField(
+ contest_place = mo_fields.Place(
'Soutěžní oblast',
description='Musí existovat soutěž v dané oblasti pro stejné kolo. Oblast zadejte pomocí kódu.'
)
@@ -116,15 +116,9 @@ class ParticipantsActionForm(FlaskForm):
if self.set_participation_state.data:
pass
elif self.set_participation_place.data:
- participation_place = db.get_place_by_code(self.participation_place.data)
- if not participation_place:
- flash('Nenalezeno místo s daným kódem', 'danger')
- return False
+ participation_place = self.participation_place.place
elif self.set_contest.data:
- contest_place = db.get_place_by_code(self.contest_place.data)
- if not contest_place:
- flash("Nepovedlo se najít "+round.get_level().name_accusative("zadaný", "zadanou", "zadané"), 'danger')
- return False
+ contest_place = self.contest_place.place
# Contest hledáme vždy v master kole, abychom náhodou nepřesunuli účastníky do soutěže v podkole
contest = sess.query(db.Contest).filter_by(round_id=round.master_round_id, place_id=contest_place.place_id).one_or_none()
if not contest:
--
GitLab