def seed_db(): db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.add(Location(lat="30.99999", lng="-120.93999")) db.session.commit()
def seed_db(): db.session.add( User(username='******', email="*****@*****.**", password="******")) db.session.add( User(username='******', email="*****@*****.**", password="******")) db.session.commit()
def seed_db(): db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.commit()
def seed_db(): db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.commit()
def seed_db(): """Seeds the database.""" db.session.add( User(username='******', email='*****@*****.**', password='******')) db.session.add( User(username='******', email='*****@*****.**', password='******')) db.session.commit()
def seed_db(): """Seeds the database.""" db.session.add( User( username="******", email="*****@*****.**", password="******", )) db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.commit()
def seed_db(): """Seeds the database.""" db.session.add( User(username="******", email="*****@*****.**", password="******")) db.session.add( User( username="******", email="*****@*****.**", password="******", )) db.session.commit()
def seed_users(): db.session.add( User(username="******", email="*****@*****.**", password="******", role="sponsor", sponsor_logo="https://logodix.com/logo/441272.png", sponsor_headline="We Deliver", sponsor_slug="The original LTL Experts")) db.session.add( User( username="******", email="*****@*****.**", password="******", role="sponsor", sponsor_logo= "https://www.jing.fm/clipimg/detail/9-98595_driving-clipart-semi-truck-semi-trucks.png", sponsor_headline="The Biggest Freight Company", sponsor_slug="We are very big.")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="admin")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="sponsor_mgr")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="sponsor_mgr")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="driver")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="driver")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="driver")) db.session.add( User(username="******", email="*****@*****.**", password="******", role="driver")) # db.session.add(User(username="", email="", password="", role="", sponsor_name="")) db.session.commit()
def seed_db(): """Seeds the database.""" db.session.add( User(username='******', email='*****@*****.**', password='******')) db.session.commit()
def register_user(): # get post data post_data = request.get_json() response_object = {"status": "fail", "message": "Invalid payload."} if not post_data: return jsonify(response_object), 400 username = post_data.get("username") email = post_data.get("email") password = post_data.get("password") try: # check for existing user user = User.query.filter( or_(User.username == username, User.email == email) ).first() if not user: # add new user to db user = User(username=username, email=email, password=password) db.session.add(user) db.session.commit() # generate auth token auth_token = user.encode_auth_token(user.id) response_object["status"] = "success" response_object["message"] = "Successfully registered." response_object["auth_token"] = auth_token.decode() return jsonify(response_object), 201 else: response_object["message"] = "Sorry. That user already exists." return jsonify(response_object), 400 # handler errors except (exc.IntegrityError, ValueError): db.session.rollback() return jsonify(response_object), 400
def post(self): post_data = request.get_json() res = {"status": "fail", "message": "invalid payload"} if not post_data: return res, 400 username = post_data.get("username") email = post_data.get("email") password = post_data.get("password") try: user = User.query.filter_by(email=email).first() if not user: db.session.add(User(username=username, email=email, password=password)) db.session.commit() res = {"status": "success", "message": f"{email} was added!"} return res, 201 else: res["message"] = "Sorry. That email already exists." return res, 400 except exc.IntegrityError: db.session.rollback() return res, 400 except (exc.IntegrityError, ValueError): db.session.rollback() return res, 400
def add_user(username, email, password): user = User(username=username, email=email, password=password) db.session.add(user) db.session.commit() return user
def post(self): post_data = request.get_json() username = post_data.get('username') email = post_data.get('email') response_object = {} user = User.query.filter_by(email=email).first() if user: response_object['message'] = 'Sorry. That email already exists.' return response_object, 400 db.session.add(User(username=username, email=email)) db.session.commit() response_object['message'] = f'{email} was added!' return response_object, 201
def post(self): post_data = request.get_json() response_object = {"status": "fail", "message": "Invalid payload."} if not post_data: return response_object, 400 username = post_data.get("username") email = post_data.get("email") try: user = User.query.filter_by(email=email).first() if not user: db.session.add(User(username=username, email=email)) db.session.commit() response_object["status"] = "success" response_object["message"] = f"{email} was added!" return response_object, 201 else: response_object[ "message"] = "Sorry. That email already exists." return response_object, 400 except exc.IntegrityError: db.session.rollback() return response_object, 400
def register_user(): post_data = request.get_json() res = {"status": "fail", "message": "Invalid payload."} if not post_data: return jsonify(res), 400 username = post_data.get("username") email = post_data.get("email") password = post_data.get("password") if not username or not email or not password: return jsonify(res), 400 try: user = User.query.filter( or_(User.username == username, User.email == email) ).first() if user: res["message"] = "Sorry, that user already exists." return jsonify(res), 400 else: new_user = User(username=username, email=email, password=password) db.session.add(new_user) db.session.commit() auth_token = new_user.encode_auth_token(new_user.id) current_app.logger.debug(f"Auth Token: {auth_token}, {type(auth_token)}") current_app.logger.debug(f"Auth Token Decode: {auth_token.decode()}") res["status"] = "success" res["message"] = "Successfully registered." res["auth_token"] = auth_token.decode() return jsonify(res), 201 except (exc.IntegrityError, ValueError): db.session.rollback() return jsonify(res), 400
def _add_user(username, email): user = User(username=username, email=email) db.session.add(user) db.session.commit() return user
def seed_db(): db.session.add(User(username="******", email="*****@*****.**")) db.session.add(User(username="******", email="*****@*****.**")) db.session.commit()
def seed_db(): db.session.add(User(username='******', email="*****@*****.**", password="******")) db.session.add(User(username='******', email="*****@*****.**", password="******")) db.session.commit()
def seed_db(): """Seeds the database.""" db.session.add(User(username='******', email="*****@*****.**")) db.session.add(User(username='******', email="*****@*****.**")) db.session.commit()
def seed_db(): user1 = User(username="******", email="*****@*****.**", password="******") user2 = User(username="******", email="*****@*****.**", password="******") db.session.add_all([user1, user2]) db.session.commit()
def seed_db(): db.session.add(User(username='******', email="*****@*****.**")) db.session.add( User(username='******', email="*****@*****.**")) db.session.commit()
def seed_db(): db.session.add(User(username='******', email="*****@*****.**")) db.session.add( User(username='******', email="*****@*****.**")) db.session.commit()
def _add_user(username, email, password="******"): user = User(username, email, password=password) db.session.add(user) db.session.commit() return user
def seed_db(): """Seeds the database.""" db.session.add(User(username='******', email="*****@*****.**")) db.session.add(User(username='******', email="*****@*****.**")) db.session.commit()
def seed_db(): db.session.add(User(username='******', email='*****@*****.**')) db.session.add(User(username='******', email='*****@*****.**')) db.session.commit()
def create_users(num_users): for _ in range(num_users): username = generate_random_string(6) user = User(username=username, email=f"{username}@gmail.com") db.session.add(user)
def seed_db(): db.session.add(User(username='******', email="*****@*****.**")) db.session.add(User(username='******', email="*****@*****.**")) db.session.commit()