Browse Source

Resolve error when player with Role.none requests a dashboard

testing
Burathar 4 years ago
parent
commit
1922464ca1
  1. 6
      app/main/routes.py
  2. 4
      app/models/user.py

6
app/main/routes.py

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import json
from datetime import datetime, timedelta
from flask import render_template, redirect, url_for, request, abort, send_file, current_app
from flask import render_template, redirect, url_for, request, abort, send_file, current_app, flash
from flask_login import current_user, login_required
from werkzeug.security import safe_join
from app import db
@ -41,8 +41,8 @@ def game_dashboard(game_name): @@ -41,8 +41,8 @@ def game_dashboard(game_name):
hunter_delay=hunter_delay, json=json,
location_encoder=LocationEncoder)
if role == Role.none:
return render_template('game_hunter_dashboard.html', title='Game Dashboard', game=game,
json=json, location_encoder=LocationEncoder)
flash('Please ask your game owner for a role to join this game')
return abort(403)
if role is None:
abort(403)

4
app/models/user.py

@ -50,7 +50,7 @@ class User(UserMixin, db.Model): @@ -50,7 +50,7 @@ class User(UserMixin, db.Model):
offset (int): Offset in minutes. Only locations older than this amount of minutes will be returned.
'''
# pylint: disable=not-an-iterable
if offset is None:
if offset is None or offset == '':
offset = 0
if not self.locations:
return None
@ -77,7 +77,7 @@ class User(UserMixin, db.Model): @@ -77,7 +77,7 @@ class User(UserMixin, db.Model):
offset (int): Offset in minutes. Only locations older than this amount of minutes will be returned.
'''
# pylint: disable=[not-an-iterable, unsubscriptable-object]
if offset is None:
if offset is None or offset == '':
offset = 0
if not self.locations:
return None

Loading…
Cancel
Save