|
|
@ -99,6 +99,17 @@ def right_for_team(team): |
|
|
|
return team.user_id == g.user.id |
|
|
|
|
|
|
|
|
|
|
|
def right_for_step(game): |
|
|
|
if right_for_game(game): |
|
|
|
if g.org: |
|
|
|
if game.step_mode == db.StepMode.org: |
|
|
|
return True |
|
|
|
if game.step_mode == db.StepMode.user: |
|
|
|
return True |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def game_link(game): |
|
|
|
b = html.Builder() |
|
|
|
with b.line(): |
|
|
@ -226,6 +237,11 @@ def web_game(game_id): |
|
|
|
|
|
|
|
b = BasePage() |
|
|
|
b.h2("Hra ", game.print()) |
|
|
|
with b.line().p("Aktuální kolo: "): |
|
|
|
if game.working_on_next_state: |
|
|
|
b.b()(game.current_round, "++") |
|
|
|
else: |
|
|
|
b(game.current_round) |
|
|
|
with b.p().table(_class="data full"): |
|
|
|
with b.thead(): |
|
|
|
b.line().th()("Id") |
|
|
@ -242,8 +258,26 @@ def web_game(game_id): |
|
|
|
if g.org: |
|
|
|
b.a(_class="btn btn-xs btn-default", href=app.url_for(web_org_game_userchange.__name__, game_id=game.game_id, team_id=team.team_id))("Změnit uživatele") |
|
|
|
|
|
|
|
with b.div(_class="btn-gruser_idoup", role="group"): |
|
|
|
if right_for_step(game): |
|
|
|
with b.form(method="POST", _class="btn-group", action=app.url_for(web_game_step.__name__, game_id=game_id)): |
|
|
|
b.button(_class="btn btn-primary", type="submit", name="su", value="yes")("Krok") |
|
|
|
|
|
|
|
return b.print_file() |
|
|
|
|
|
|
|
@app.route("/game/<int:game_id>/step", methods=['POST']) |
|
|
|
def web_game_step(game_id): |
|
|
|
ses = db.get_session() |
|
|
|
game = ses.query(db.Game).filter_by(game_id=game_id).one_or_none() |
|
|
|
if game is None: |
|
|
|
raise werkzeug.exceptions.NotFound() |
|
|
|
if not right_for_step(game): |
|
|
|
raise werkzeug.exceptions.Forbidden() |
|
|
|
|
|
|
|
lib.game_step(game_id) |
|
|
|
|
|
|
|
return redirect(app.url_for(web_game.__name__, game_id=game_id)) |
|
|
|
|
|
|
|
@app.route("/game/<int:game_id>/view", methods=['GET']) |
|
|
|
@app.route("/game/<int:game_id>/view/<int:team_id>", methods=['GET']) |
|
|
|
def web_game_view(game_id, team_id=None): |
|
|
|