def create_parent(): print("Server.py: create parentfunction") query_str_data = request.get_json() print("Server.py: ", query_str_data) parent_fname = query_str_data['parentFname'], parent_lname = query_str_data['parentLname'], email = query_str_data['email'], phone = query_str_data['phone'], address1 = query_str_data['address1'], address2 = query_str_data['address2'], city = query_str_data['city'], state = query_str_data['resState'], zipcode = query_str_data['zipcode'], last_login = datetime.now(), created_on = datetime.now(), password = query_str_data['password'] print("Server.py: ", parent_fname) try: result = crud.create_parent(parent_fname, parent_lname, email, phone, address1, address2, state, city, zipcode, last_login, created_on, password) return jsonify([result.id, email]) except: result = "Error inserting parent" return result
def test_create_parent(self): """Does parent creation product the correct result?""" testparent = create_parent(fname="Bento", lname="Willow", email="*****@*****.**", password="******", household_id=4) self.assertEqual(testparent.fname, "Bento") self.assertEqual(type(testparent), Parent)
def signup_parent(): """Create a new user.""" data = request.get_json() fname = data["fname"] lname = data["lname"] email = data["signupemail"] password = data["signuppassword"] #If email already exists in the system, block user from re-registering. #if crud.get_user_by_email(email): # return jsonify("Sorry, that user already exists. Please try again.") #Otherwise, allow user to register for an account with that email address. #else: user = crud.create_parent(fname, lname, email, password) access_token = create_access_token(identity=email) return jsonify({"access_token": access_token})
model.db.session.commit() i += 1 #Create parents in db: j = 1 for _ in range(20): fname = fake.first_name() lname = fake.last_name() email = fake.ascii_email() password = fake.password(length=6) household_id = j mobile_number = fake.phone_number() new_parent = crud.create_parent(fname=fname, lname=lname, email=email, password=password, household_id=household_id, mobile_number=mobile_number) j += 1 eric = crud.create_parent(fname="Eric", lname="Anderson", email="*****@*****.**", password="******", household_id=11, mobile_number="917-538-4741") marcy = crud.create_parent(fname="Marcy", lname="Anderson", email="*****@*****.**", password="******", household_id=11,
parent[1], parent[2], parent[3], parent[4], parent[5], parent[6], parent[7], parent[8], parent[9], parent[10], parent[11], ) # Call create_parent function from crud.py db_parent = crud.create_parent(parent_fname, parent_lname, \ email, phone, address1, address2, \ city, state, zipcode, last_login, \ created_on, password) ########### CHILDREN DATA # Load children data from JSON file generated using Faker with open('data/children.json') as f: children_info = json.loads(f.read()) # Create & load child for child in children_info: # Unpack the values & send as a list to create a record in the backend db child_fname, child_lname, grade, \ school_id, parent_id = (child[0], child[1],