From e06800627540f6cb770aa305028607cc3d6bf611 Mon Sep 17 00:00:00 2001 From: Burathar Date: Mon, 6 Jul 2020 23:13:20 +0200 Subject: [PATCH] Add game_dashboard --- app/routes.py | 13 ++++++++----- app/templates/game_dashboard.html | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/app/routes.py b/app/routes.py index 6357a14..a3913f7 100644 --- a/app/routes.py +++ b/app/routes.py @@ -50,11 +50,14 @@ def create_game(): if form.validate_on_submit(): game = Game(name=form.game_name.data, start_time=form.start_time.data, end_time=form.end_time.data) game.gameplayers.append(GamePlayer(player=current_user, role=Role['owner'])) #check if this works, otherwise use 'owner' - print(game.start_time) - return render_template('create_game.html', title='Create Game', form=form) + db.session.add(game) + db.session.commit() + flash(f"'{game.name}' had been created!") + return redirect(url_for('game_dashboard', game_name=game.name)) return render_template('create_game.html', title='Create Game', form=form) @login_required -@app.route('/game//admin') -def game_dashboard(): - return render_template('game_dashboard.html', title = 'Game Dashboard') \ No newline at end of file +@app.route('/game//dashboard') +def game_dashboard(game_name): + game = Game.query.filter(Game.game_players.any(and_(GamePlayer.player.has(current_user), GamePlayer.role == 'owner'))).first_or_404() + return render_template('game_dashboard.html', title = 'Game Dashboard', game=game) \ No newline at end of file diff --git a/app/templates/game_dashboard.html b/app/templates/game_dashboard.html index 0df7b55..0c11bf3 100644 --- a/app/templates/game_dashboard.html +++ b/app/templates/game_dashboard.html @@ -1,5 +1,34 @@ {% extends 'base.html' %} {% block app_content %} -

Dashboard

+

{{ game.name }}Dashboard

+ +

Players:

+
+ + + + + + + + + + + + {% for player in game.players %} + + + + + + + {% endfor %} + +
Player NameRoleObjectives foundBunnies CaughtLast location
{{ player.name }}{{ [gameplayer for gameplayer in p.player_games if gameplayer.game == g2][0].role }}{{ "Placeholder" }}{{ "Placeholder" }} Placeholder +
+
+ + + {% endblock %} \ No newline at end of file