diff --git a/goodplays/authenticate.py b/goodplays/authenticate.py index 2e075df..2f45333 100755 --- a/goodplays/authenticate.py +++ b/goodplays/authenticate.py @@ -2,8 +2,8 @@ from json import loads import requests -from template import app -from template.models import User +from goodplays import app +from goodplays.models import User def authenticate(username, password): diff --git a/goodplays/models.py b/goodplays/models.py index 065513f..550467b 100755 --- a/goodplays/models.py +++ b/goodplays/models.py @@ -4,6 +4,7 @@ class User(db.Model): + __tablename__ = 'User' id = db.Column(db.String, primary_key=True) name = db.Column(db.String, index=True, unique=True) email = db.Column(db.String, index=True) @@ -55,6 +56,7 @@ def __repr__(self): class Platform(db.Model): + __tablename__ = 'Platform' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, unique=True) games = db.relationship( @@ -70,6 +72,7 @@ def __repr__(self): class Game(db.Model): + __tablename__ = 'Game' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) year = db.Column(db.Integer) @@ -96,12 +99,8 @@ def __repr__(self): ) -# TODO: Seems like there's circular table dependency issue or something. -# Try to resolve it. If you can't, get rid of the secondaries and create some -# intermediate link table classes manually. - - class Tag(db.Model): + __tablename__ = 'Tag' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, unique=True) plays = db.relationship( @@ -117,6 +116,7 @@ def __repr__(self): class Play(db.Model): + __tablename__ = 'Play' id = db.Column(db.Integer, primary_key=True) started = db.Column(db.Date) finished = db.Column(db.Date) @@ -129,9 +129,8 @@ class Play(db.Model): lazy='dynamic', cascade='all, delete-orphan' ) - game_id = db.Column(db.Integer, db.ForeignKey('game.id')) - user_id = db.Column(db.Integer, db.ForeignKey('user.id')) + game_id = db.Column(db.Integer, db.ForeignKey('Game.id')) + user_id = db.Column(db.Integer, db.ForeignKey('User.id')) def __repr__(self): return ''.format(self.name) - diff --git a/goodplays/views.py b/goodplays/views.py index 9fb257f..94cc473 100755 --- a/goodplays/views.py +++ b/goodplays/views.py @@ -1,6 +1,5 @@ from flask import render_template, flash, redirect, session, url_for, request from flask_login import login_user, logout_user, current_user, login_required -import ldap3 from goodplays import app, db, lm from goodplays.forms import LoginForm @@ -21,11 +20,11 @@ def latest(): Maybe set up a daily task to update this DB? It'll get big...) """ user = current_user - games = Game.query. # TODO 10 latest! + games = [] #Game.query. # TODO 10 latest! # TODO Show most recent 10 games added to the DB. - if not objects: + if not games: flash("Games don't exist. Good riddance. Thanks, Tauriq!") return render_template( @@ -56,7 +55,7 @@ def plays(): @app.route('/login', methods=['GET', 'POST']) def login(): """ - Logs the user in using LDAP authentication. + Logs the user in """ if current_user is not None and current_user.is_authenticated: return redirect(url_for('index'))