From 7ecfc4bafc75a125c73e03bd630f065d9e4ed40c Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Fri, 4 Jun 2021 21:29:42 +0530 Subject: added superuser --- app/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'app/__init__.py') diff --git a/app/__init__.py b/app/__init__.py index 1c759e7..9f025af 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -22,7 +22,16 @@ def create_database(): db.create_all() @database_cli.command("delete") def delete_database(): - db.drop_all() + db.drop_all() +@database_cli.command("admin-create") +def make_superuser_database(): + user = User( + first_name="Supersu", + email=app.config["ADMIN_EMAIL"], + password=app.config["ADMIN_PASSWORD"], + role="SUPERUSER") + db.session.add(user) + db.session.commit() app.cli.add_command(database_cli) -- cgit v1.2.3