From 3b8e28b4f3480e37d99fbef9139cc58c923850da Mon Sep 17 00:00:00 2001 From: Leo VIALLON-GALINIER Date: Sat, 25 Apr 2020 13:00:42 +0200 Subject: [PATCH] Remove test parts and adjust db --- belote.py | 9 +-------- db.py | 12 ++++++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/belote.py b/belote.py index 0f9268d..8d0e9a7 100644 --- a/belote.py +++ b/belote.py @@ -35,13 +35,6 @@ if User.query.limit(1).first() is None: db.session.add(admin) db.session.commit() -for i in range(4): - if User.query.get('leo'+str(i)) is None: - leo = User(login='leo'+str(i), name='Leo '+str(i), level=levels_users['Can manage simple users']) - leo.set_password('leo') - db.session.add(leo) -db.session.commit() - # Login management @login_manager.user_loader def load_user(user_id): @@ -369,5 +362,5 @@ def delete_game(user=None, game=None): if __name__ == '__main__': - socketio.run(app, debug=True, host='0.0.0.0') + socketio.run(app, debug=True, host='127.0.0.1') diff --git a/db.py b/db.py index 03012bf..65e59b3 100644 --- a/db.py +++ b/db.py @@ -18,12 +18,12 @@ class User(UserMixin, db.Model): __tablename__ = 'users' - login = db.Column(db.String(200), + login = db.Column(db.String(100), primary_key=True) - name = db.Column(db.String(200), + name = db.Column(db.String(100), nullable=False, unique=False) - password = db.Column(db.String(200), + password = db.Column(db.String(100), primary_key=False, unique=False, nullable=False) @@ -53,12 +53,12 @@ class Game(db.Model): id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(200)) + name = db.Column(db.String(100)) players = relationship("Player") turn = db.Column(db.Integer, default=-8) atout = db.Column(db.String(1)) preneur = db.Column(db.Integer) - admin = db.Column(db.String(200), db.ForeignKey('users.login')) + admin = db.Column(db.String(100), db.ForeignKey('users.login')) cards_to_distribute = db.Column(db.String(200)) first_player = db.Column(db.Integer) start = db.Column(db.Boolean, default=False) @@ -332,7 +332,7 @@ class Player(db.Model): id = db.Column(db.Integer, primary_key=True) game = db.Column(db.Integer, db.ForeignKey('games.id')) - user = db.Column(db.Integer, db.ForeignKey('users.login')) + user = db.Column(db.String(100), db.ForeignKey('users.login')) cards = db.Column(db.String(40)) nr = db.Column(db.Integer, default=-1)