コード例 #1
0
ファイル: database.py プロジェクト: kurushdubash/dreamspace
def get_user(username):
    hash_id = hash_username(username)
    response = fireb.get("/users/", name=hash_id)
    if not response:
        return None
    if response['account']['account_type'] == 'Facebook':
        email = ''
        if 'email' in response:
            email = response['email']
        user = server.User(response['username'], response['pass_hash'], email,
                           response['name'], 'Facebook')
        user.facebook_token = response['pass_hash']
    else:
        user = server.User(response['username'], response['pass_hash'],
                           response['email'], response['name'])
    user.password_hash = response['pass_hash']
    if 'dreams' in response:
        user.dreams = response['dreams']
    return user
コード例 #2
0
        cursor.close()


db = SQLAlchemy(app)
now = datetime.now()

faker = Faker()

# create dummy users
for i in range(200):
    name = faker.name()
    address = faker.address()
    phone = faker.msisdn()
    email = f'{name.replace(" ", "_")}@email.com'
    new_user = server.User(name=name,
                           address=address,
                           phone=phone,
                           email=email)
    db.session.add(new_user)
    db.session.commit()

# create dummy blog posts
for i in range(200):
    title = faker.sentence(5)
    body = faker.paragraph(190)
    date = faker.date_time()
    user_id = randrange(1, 200)

    new_blog_post = server.BlogPost(title=title,
                                    body=body,
                                    date=date,
                                    user_id=user_id)