Ejemplo n.º 1
0
def createall():
    """
    Creates the database with some example content
    Attention: This will delete your whole database (if one exists)
    """

    # Be sure that there isn't a existing one.
    db.drop_all()

    db.create_all()

    user1 = User(username="******", password="******", email="*****@*****.**",
                 theme=current_app.config["DEFAULT_THEME"],
                 language=current_app.config["BABEL_DEFAULT_LOCALE"],
                 is_admin=True)
    user1.save()

    user2 = User(username="******", password="******", email="*****@*****.**",
                 theme="bootstrap2", language="de", is_admin=False)

    user2.save()

    post = Post(title="Example 1", content="Example Content",
                date_created=datetime.datetime.utcnow())
    post.save(user1)

    comment = Comment(content="Test Comment",
                      date_created=datetime.datetime.utcnow())
    comment.save(user2, post)
Ejemplo n.º 2
0
def initdb():
    """
    Creates the database.
    """

    db.create_all()