From 1bb59161d8c13a38d6a5937b23d00c72eef8e990 Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda Date: Mon, 26 Sep 2022 16:36:42 +0200 Subject: [PATCH] =?UTF-8?q?Strategick=C3=A1:=20Zobrazov=C3=A1n=C3=AD=20sta?= =?UTF-8?q?r=C5=A1=C3=ADch=20kol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/hra/web/game.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/hra/web/game.py b/server/hra/web/game.py index 129f1a3..a5f0eb9 100644 --- a/server/hra/web/game.py +++ b/server/hra/web/game.py @@ -19,7 +19,7 @@ import hra.db as db from hra.web import app import hra.web.jinja_mac as jinja_mac from hra.util import hash_passwd -from hra.web.pages import BasePage, web_game_view, right_for_team +from hra.web.pages import BasePage, web_game_view, right_for_team, OptionalIntField wlogic_by_mode = {} @@ -59,6 +59,8 @@ class OccupyViewConfig(FlaskForm): status = RadioField("", choices=(status_minimalistic, status_left, status_up), default=status_minimalistic) big_fields = BooleanField("Široká políčka (trojciferné počty)") + round = OptionalIntField("Kolo k zobrazení") + submit = SubmitField("Refresh/Potvrdit") show_data_only = SubmitField("Zobrazit stránku pouze s daty") @@ -67,7 +69,15 @@ class Occupy(WLogic): def view(self, state: db.State, team: Optional[db.Team], teams: List[db.Team]): meta_refresh_without_reaming = 15 + conff = OccupyViewConfig(formdata=request.args, csrf_enabled=False) + conff.validate() + game = state.game + if conff.round.data is not None: + state = db.get_session().query(db.State).filter_by(game_id=game.game_id, round=conff.round.data).one_or_none() + if state is None: + raise werkzeug.exceptions.NotFound("Zadané kolo neexisstuje") + team_id = team.team_id if team else None if game.step_mode == db.StepMode.automatic: time_reaming = (state.create_time - datetime.now()).total_seconds() + game.step_every_s @@ -76,9 +86,7 @@ class Occupy(WLogic): s = state.get_state() if team is not None: s = self.logic.personalize_state(s, team.team_id, state.round) - conff = OccupyViewConfig(formdata=request.args, csrf_enabled=False) q = db.get_session().query(db.Log).order_by(db.Log.log_id.desc()) - conff.validate() moves = []