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)
def save(self, theme, language): user = User(username=self.username.data, email=self.email.data, password=self.password.data, date_joined=datetime.utcnow(), language=language, theme=theme) return user.save()