add dummy-data flask command

This commit is contained in:
Son 2021-08-15 17:32:54 +02:00
parent 1384ccc459
commit 4cbbf260d4
1 changed files with 9 additions and 6 deletions

View File

@ -204,13 +204,7 @@ def create_app() -> Flask:
def fake_data():
LOG.d("create fake data")
# Remove db if exist
if os.path.exists("db.sqlite"):
LOG.d("remove existing db file")
os.remove("db.sqlite")
# Create all tables
db.create_all()
# Create a user
user = User.create(
@ -918,6 +912,15 @@ def register_custom_commands(app):
LOG.d("finish trunk %s, update %s email logs", trunk, nb_update)
db.session.commit()
@app.cli.command("dummy-data")
def dummy_data():
from init_app import add_sl_domains
LOG.warning("reset db, add fake data")
with app.app_context():
fake_data()
add_sl_domains()
def setup_do_not_track(app):
@app.route("/dnt")