Exemplo n.º 1
0
def add_twit():
    form = addTwitForm()
    if form.validate_on_submit():
        twit = form.twit.data
        db.add_twit(twit, session['user_id'])
        return redirect(vs_url_for('index'))
    return render_template('add_twit_mysql.html', form=form)
Exemplo n.º 2
0
def add_twit():
    form = addTwitForm()
    if form.validate_on_submit():
        twit = form.twit.data
        user_id = current_user.user_id
        db.add_twit(twit, user_id)
        return redirect(vs_url_for('.index'))
    return render_template('add_twit_mysql.html', form=form)
Exemplo n.º 3
0
def add_twit():
    form = addTwitForm()
    if form.validate_on_submit():
        twit = form.twit.data
        user_id = current_user.user_id
        new_twit = Twits(twit=twit, user_id=user_id)
        db.session.add(new_twit)
        db.session.commit()
        return redirect(vs_url_for('index'))
    return render_template('add_twits.html', form=form)
Exemplo n.º 4
0
def add_twit():
    form = addTwitForm()
    if form.validate_on_submit():
        twit = form.twit.data
        user_id = current_user.user_id
        new_twit = Twits(twit=twit, user_id=user_id)
        # we need to add the object to the flask-sqlalchemy session
        # and then commit our changes for it to be inserted in to the database
        db.session.add(new_twit)
        db.session.commit()
        return redirect(vs_url_for('index'))
    return render_template('add_twit_mysql.html', form=form)
def add_twit():
    form = addTwitForm()
    if form.validate_on_submit():
        twit = form.twit.data
        user_id = current_user.user_id
        # SQLAlchemy adds an implicit constructor to all model classes which
        # accepts keyword arguments for all its columns and relationships.
        # We can use this to create our new twit
        new_twit = Twits(twit=twit, user_id=user_id)
        # As explained in http://flask-sqlalchemy.pocoo.org/2.3/queries/
        # we need to add the object to the flask-sqlalchemy session
        # and then commit our changes
        # for it to be inserted in to the database
        db.session.add(new_twit)
        db.session.commit()
        return redirect(vs_url_for('index'))
    return render_template('add_twit_mysql.html',form=form)