from app import create_app, db from app.models import Game, User, Objective, Location, Notification, GamePlayer, \ PlayerFoundObjective, NotificationPlayer, PlayerCaughtPlayer, Role, GameState, Review app = create_app() @app.shell_context_processor def make_shell_context(): return {'db': db, 'Game' : Game, 'User' : User, 'Objective' : Objective, 'Location' : Location, 'Notification' : Notification, 'GamePlayer' : GamePlayer, 'PlayerFoundObjective' : PlayerFoundObjective, 'NotificationPlayer' : NotificationPlayer, 'PlayerCaughtPlayer' : PlayerCaughtPlayer, 'Role' : Role, 'GameState' : GameState, 'Review' : Review, 'create_objects' : create_objects} def create_objects(): g1 = Game(name='TestGame') g2 = Game(name='MyGame') u1 = User(name='Marijn') u1.set_password('123') u2 = User(name='Rogier') u2.set_password('123') u3 = User(name='Henk') u4 = User(name='Emma') u5 = User(name='Demi') o1 = Objective(name='Florin', latitude=52.0932, longitude=5.12405) o2 = Objective(name='Amsterdam', latitude=52.35547, longitude=4.87518) o3 = Objective(name='Amersfoort', latitude=52.17056, longitude=5.39154) o1.set_hash() o2.set_hash() o3.set_hash() g1.players.append(GamePlayer(user=u1, role=Role.owner)) g1.players.append(GamePlayer(user=u2, role=Role.hunter)) g1.players.append(GamePlayer(user=u3, role=Role.hunter)) g1.players.append(GamePlayer(user=u4, role=Role.bunny)) g1.players.append(GamePlayer(user=u5, role=Role.bunny)) g1.objectives.append(o1) g1.objectives.append(o2) g1.objectives.append(o3) g2.players.append(GamePlayer(user=u1, role=Role.bunny)) g2.players.append(GamePlayer(user=u2, role=Role.owner)) g2.players.append(GamePlayer(user=u3, role=Role.hunter)) db.session.add(g1) db.session.add(g2) db.session.commit()