def make_random_user(password_hash): # Make the user first_name, last_name = gen_new_name(user_names_used, first_names, last_names) if first_name is None: return user_names_used.add((first_name, last_name)) if random.randint(0, 1): searcher_role = 'educator' searching_for_role = 'partner' bio = generate_educator_bio() associations = [gen_random_institution(schools, educator_roles)] else: searcher_role = 'partner' searching_for_role = 'educator' bio = generate_expert_bio() associations = [ gen_random_institution(companies, partner_roles) for _ in range(random.randint(1, 2)) ] new_user = User( name='{0} {1}'.format(first_name, last_name), email=gen_email(first_name, last_name), password_hash=password_hash, picture_filename=random.choice(profile_picture_filenames), bio=bio, institution_associations=associations, is_administrator=False, email_confirmed=True ) store.session.add(new_user) store.session.commit() # Make the search latitude, longitude = make_random_location() search = Search( searcher_user_id=new_user.id, searcher_role=searcher_role, searching_for_role=searching_for_role, latitude=latitude, longitude=longitude, ) search.labels = Label.name_list_to_object_list(gen_labels()) store.session.add(search) store.session.commit() if search.searcher_role == 'educator': new_user.educator_profile_search = search else: new_user.community_partner_profile_search = search store.session.add(new_user) store.session.commit()