Browse Source

Add game_dashboard

feature_tests
Burathar 4 years ago
parent
commit
e068006275
  1. 13
      app/routes.py
  2. 31
      app/templates/game_dashboard.html

13
app/routes.py

@ -50,11 +50,14 @@ def create_game():
if form.validate_on_submit(): 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 = 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.gameplayers.append(GamePlayer(player=current_user, role=Role['owner'])) #check if this works, otherwise use 'owner'
print(game.start_time) db.session.add(game)
return render_template('create_game.html', title='Create Game', form=form) 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) return render_template('create_game.html', title='Create Game', form=form)
@login_required @login_required
@app.route('/game/<game_name>/admin') @app.route('/game/<game_name>/dashboard')
def game_dashboard(): def game_dashboard(game_name):
return render_template('game_dashboard.html', title = 'Game Dashboard') 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)

31
app/templates/game_dashboard.html

@ -1,5 +1,34 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block app_content %} {% block app_content %}
<h1>Dashboard</h1> <h1>{{ game.name }}Dashboard</h1>
<h2>Players:</h2>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">Player Name</th>
<th scope="col">Role</th>
<th scope="col">Objectives found</th>
<th scope="col">Bunnies Caught</th>
<th scope="col">Last location</th>
</tr>
</thead>
<tbody>
{% for player in game.players %}
<tr>
<td><a href="{{ url_for(f'player/{player.name}') }}">{{ player.name }}</a></td>
<td>{{ [gameplayer for gameplayer in p.player_games if gameplayer.game == g2][0].role }}</td>
<td>{{ "Placeholder" }}</td>
<td>{{ "Placeholder" }}</td>
<td> Placeholder <td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %} {% endblock %}
Loading…
Cancel
Save