|
|
@ -36,13 +36,12 @@ def index(): |
|
|
|
@login_required |
|
|
|
@login_required |
|
|
|
def create_game(): |
|
|
|
def create_game(): |
|
|
|
form = CreateGameForm() |
|
|
|
form = CreateGameForm() |
|
|
|
form.state.choices = [(state.value, state.name) for state in GameState] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if form.validate_on_submit(): |
|
|
|
if form.validate_on_submit(): |
|
|
|
game = Game(name=form.game_name.data, |
|
|
|
game = Game(name=form.game_name.data, |
|
|
|
start_time=form.start_time.data, |
|
|
|
start_time=form.start_time.data, |
|
|
|
end_time=form.end_time.data, |
|
|
|
end_time=form.end_time.data) |
|
|
|
state=GameState(form.state.data)) |
|
|
|
game.update_state() |
|
|
|
game.players.append(GamePlayer(user=current_user, role=Role['owner'])) |
|
|
|
game.players.append(GamePlayer(user=current_user, role=Role['owner'])) |
|
|
|
db.session.add(game) |
|
|
|
db.session.add(game) |
|
|
|
db.session.commit() |
|
|
|
db.session.commit() |
|
|
@ -60,11 +59,9 @@ def change_game_settings(game_name): |
|
|
|
abort(403) |
|
|
|
abort(403) |
|
|
|
|
|
|
|
|
|
|
|
form = CreateGameForm() |
|
|
|
form = CreateGameForm() |
|
|
|
form.state.choices = [(state.value, state.name) for state in GameState] |
|
|
|
|
|
|
|
form.old_name = game.name |
|
|
|
form.old_name = game.name |
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'GET': |
|
|
|
if request.method == 'GET': |
|
|
|
form.state.default = game.get_state().value |
|
|
|
|
|
|
|
# pylint: disable=no-member |
|
|
|
# pylint: disable=no-member |
|
|
|
form.process() |
|
|
|
form.process() |
|
|
|
form.game_name.data = game.name |
|
|
|
form.game_name.data = game.name |
|
|
@ -83,7 +80,7 @@ def change_game_settings(game_name): |
|
|
|
game.name = form.game_name.data |
|
|
|
game.name = form.game_name.data |
|
|
|
game.start_time = form.start_time.data |
|
|
|
game.start_time = form.start_time.data |
|
|
|
game.end_time = form.end_time.data |
|
|
|
game.end_time = form.end_time.data |
|
|
|
game.state = GameState(form.state.data) |
|
|
|
game.update_state() |
|
|
|
db.session.commit() |
|
|
|
db.session.commit() |
|
|
|
flash(f"'{game.name}' had been updated!") |
|
|
|
flash(f"'{game.name}' had been updated!") |
|
|
|
return redirect(url_for('main.game_dashboard', game_name=game.name)) |
|
|
|
return redirect(url_for('main.game_dashboard', game_name=game.name)) |
|
|
|