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 @@
import json import json
from datetime import datetime, timedelta 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 flask_login import current_user, login_required
from werkzeug.security import safe_join from werkzeug.security import safe_join
from app import db from app import db
@ -41,8 +41,8 @@ def game_dashboard(game_name):
hunter_delay=hunter_delay, json=json, hunter_delay=hunter_delay, json=json,
location_encoder=LocationEncoder) location_encoder=LocationEncoder)
if role == Role.none: if role == Role.none:
return render_template('game_hunter_dashboard.html', title='Game Dashboard', game=game, flash('Please ask your game owner for a role to join this game')
json=json, location_encoder=LocationEncoder) return abort(403)
if role is None: if role is None:
abort(403) abort(403)

4
app/models/user.py

@ -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. offset (int): Offset in minutes. Only locations older than this amount of minutes will be returned.
''' '''
# pylint: disable=not-an-iterable # pylint: disable=not-an-iterable
if offset is None: if offset is None or offset == '':
offset = 0 offset = 0
if not self.locations: if not self.locations:
return None return None
@ -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. offset (int): Offset in minutes. Only locations older than this amount of minutes will be returned.
''' '''
# pylint: disable=[not-an-iterable, unsubscriptable-object] # pylint: disable=[not-an-iterable, unsubscriptable-object]
if offset is None: if offset is None or offset == '':
offset = 0 offset = 0
if not self.locations: if not self.locations:
return None return None

Loading…
Cancel
Save