コード例 #1
0
def create_user(email=EXAMPLE_EMAIL, password=EXAMPLE_PASSWORD):
    user = User.create(email, password)
    # store = Store(name=STORE_NAME, user=user)
    # db.session.add(store)
    db.session.add(user)
    db.session.commit()
    return user
コード例 #2
0
def user_with_product():
    new_user = User.create("*****@*****.**", "pass")
    store = Store(name="Test Store", user=new_user)
    product = Product(name='Test Product',
                      description='a product',
                      store=store)
    db.session.add(product)
    db.session.commit()
    yield new_user
コード例 #3
0
def sample_book():
    new_user = User.create('*****@*****.**', 'examplepass')
    db.session.add(new_user)
    store = Store(name='Store Name', user=new_user)
    # db.session.add(store)
    book = Product(name="Sherlock Homes",
                   store=store,
                   description="A house hunting detective")
    db.session.add(book)
    db.session.commit()
    return book
コード例 #4
0
ファイル: seed.py プロジェクト: frivolta/flask-rest-yumroad
def setup():
    with app.app_context():
        db.create_all()
        user = User.create("*****@*****.**", "test")
        db.session.add(user)
        store = Store(name="The newline store", user=user)
        for i in range(2):
            prod = Product(name='Fullstack Book v{}'.format((1+i)),
                           description='Book #{} in the series'.format(i+1),
                           price_cents=100*(i+1),
                           store=store)
            db.session.add(prod)
        db.session.commit()
コード例 #5
0
def authenticated_request(client):
    new_user = User.create('*****@*****.**', 'examplepass')
    store = Store(name="Test Store", user=new_user)
    db.session.add(new_user)
    db.session.commit()

    response = client.post(url_for('user.login'),
                           data={
                               'email': '*****@*****.**',
                               'password': '******'
                           },
                           follow_redirects=True)
    yield client
コード例 #6
0
ファイル: users.py プロジェクト: DentonPaul/yumroad-app
def register():
    if current_user.is_authenticated:
        flash('You are already logged in', 'warning')
        return redirect(url_for('products.index'))
    form = SignupForm()
    if form.validate_on_submit():
        # create a user
        user = User.create(form.email.data, form.password.data)
        db.session.add(user)
        store = Store(name=form.store_name.data,
                      user=user)  # may need another db.session.add(store)
        db.session.commit()
        login_user(user)
        send_welcome_message(user)
        flash("Registered successfully", "success")
        return redirect(url_for('products.index'))
    return render_template('users/register.html', form=form)
コード例 #7
0
ファイル: users.py プロジェクト: frivolta/flask-rest-yumroad
def register():
    if current_user.is_authenticated:
        flash("You are already logged in", 'warning')
        return redirect(url_for("product.index"))

    form = SignupForm()
    if form.validate_on_submit():
        user = User.create(form.email.data, form.password.data)
        db.session.add(user)
        store = Store(name=form.store_name.data, user=user)
        db.session.add(store)
        db.session.commit()

        send_pretty_welcome_message(user)
        login_user(user)
        flash("Registered succesfully.", "success")
        return redirect(session.get('after_login') or url_for("product.index"))

    return render_template("users/register.html", form=form)
コード例 #8
0
def create_user(email=EXAMPLE_EMAIL, password=EXAMPLE_PASSWORD):
    user = User.create(email, password)
    db.session.add(user)
    db.session.commit()
    return user