diff --git a/app/routes.py b/app/routes.py index a3913f7..c306e44 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,7 +1,8 @@ from flask import render_template, flash, redirect, url_for, request from flask_login import login_user, logout_user, current_user, login_required +from sqlalchemy import and_ from app import app, db -from app.models import Player, Game, Role +from app.models import Player, Game, Role, GamePlayer from app.forms import LoginForm, RegistrationForm, CreateGameForm @app.route('/', methods=['GET']) @@ -49,7 +50,7 @@ def create_game(): form = CreateGameForm() 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' + game.game_players.append(GamePlayer(player=current_user, role=Role['owner'])) #check if this works, otherwise use 'owner' db.session.add(game) db.session.commit() flash(f"'{game.name}' had been created!") @@ -59,5 +60,10 @@ def create_game(): @login_required @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 + game = Game.query.filter(Game.game_players.any(and_(GamePlayer.player.has(Player.name == current_user.name), GamePlayer.role == 'owner'))).first_or_404() + return render_template('game_dashboard.html', title = 'Game Dashboard', game=game) + +@login_required +@app.route('/game//player/') +def game_player(game_name, player_name): + return render_template("index.html", title='Home') \ No newline at end of file diff --git a/app/templates/game_dashboard.html b/app/templates/game_dashboard.html index 0c11bf3..ca190d6 100644 --- a/app/templates/game_dashboard.html +++ b/app/templates/game_dashboard.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block app_content %} -

{{ game.name }}Dashboard

+

{{ game.name }} Dashboard

Players:

@@ -18,8 +18,10 @@ {% for player in game.players %} - {{ player.name }} - {{ [gameplayer for gameplayer in p.player_games if gameplayer.game == g2][0].role }} + {{ player.name }} + {% for gameplayer in player.player_games if gameplayer.game == game %} + {{ gameplayer.role.name }} + {% endfor %} {{ "Placeholder" }} {{ "Placeholder" }} Placeholder diff --git a/app/templates/index.html b/app/templates/index.html index d92fb17..02b2f57 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -20,12 +20,12 @@ {% for game in current_user.games %} {{ game.name }} - {{ game.state }} + {{ game.state.name}} {{ game.start_time }} {{ game.end_time }} - {% for gameplayer in current_user.player_games %} - {% if gameplayer.game == game %}{{ gameplayer.role }}{% endif %} + {% for gameplayer in current_user.player_games if gameplayer.game == game %} + {{ gameplayer.role.name }} {% endfor %}