コード例 #1
0
def user_without_email(db):
    """Create a simple invenio user without email."""
    with db.session.begin_nested():
        user = User(
            password=hash_password('123456'),
            profile=dict(), active=True)
        db.session.add(user)
        profile = user.profile
        profile.birth_date = datetime(1990, 1, 1)
        profile.first_name = 'User'
        profile.last_name = 'With Profile'
        profile.city = 'Nowhere'
        profile.username = '******'
        db.session.merge(user)
    db.session.commit()
    user.password_plaintext = '123456'
    return user