Add config manipulation to manage.py (#1233)

* Adds `get_config` and `set_config` commands to `manage.py` to manipulate the Config table from a CLI
* Closes #1226
bulk-clear-sessions
Kevin Chung 2020-02-12 01:27:06 -05:00 committed by GitHub
parent 1049a14b90
commit 354954bbe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -3,6 +3,7 @@ from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand from flask_migrate import Migrate, MigrateCommand
from CTFd import create_app from CTFd import create_app
from CTFd.utils import get_config as get_config_util, set_config as set_config_util
from CTFd.models import * from CTFd.models import *
app = create_app() app = create_app()
@ -10,5 +11,18 @@ app = create_app()
manager = Manager(app) manager = Manager(app)
manager.add_command('db', MigrateCommand) manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
@manager.command
def get_config(key):
with app.app_context():
print(get_config_util(key))
@manager.command
def set_config(key, value):
with app.app_context():
print(set_config_util(key, value).value)
if __name__ == "__main__":
manager.run() manager.run()