Example #1
0
def root():
    try:
        users = User.query.all()
    except Exception as e:
        DB.drop_all()
        DB.create_all()
        users = User.query.all()
    return render_template('base.html', title='Home', users=users)
Example #2
0
def reset():
    DB.drop_all()  # Reset the DB
    DB.create_all()
    return render_template('base.html', title='Reset database!')
Example #3
0
def setup_test_users():
    DB.drop_all()
    DB.create_all()  # initial setup
    add_test_users()
    return render_template('admin.html', message='test users added')
Example #4
0
# to run in flask shell: exec(open("./add_users.py").read())
from twitoff.models import DB, User, Tweet

DB.drop_all()
DB.create_all()

u1 = User(name='Mort')
t1 = Tweet(text='What time is it?')
t2 = Tweet(text='Are these my shoes?')
t3 = Tweet(text='Not my chair, not my problem.')

u1.tweets += [t1, t2, t3]

u2 = User(name='Jack')
t4 = Tweet(text='Rocket 88')
t5 = Tweet(text='Deep Deep Sleep')
t6 = Tweet(text="Somethin' Else")

u2.tweets += [t4, t5, t6]

adds = [u1, u2, t1, t2, t3, t4, t5, t6]
for add in adds:
    DB.session.add(add)
DB.session.commit()
Example #5
0
def reset():
    DB.drop_all()
    DB.create_all()
    return redirect("/")
Example #6
0
 def reset():
     # resets database
     DB.drop_all()
     DB.create_all()
     return render_template('base.html', title='Home')