diff --git a/app/__init__.py b/app/__init__.py index 41a8074d..4b7f545e 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -99,7 +99,7 @@ def create_app(config: Config = Config) -> Flask: from .users import bp as users_blueprint default_breadcrumb_root(users_blueprint, '.users') - app.register_blueprint(users_blueprint, url_prefix='/users') + app.register_blueprint(users_blueprint, cli_group='user', url_prefix='/users') from .workshops import bp as workshops_blueprint app.register_blueprint(workshops_blueprint, url_prefix='/workshops') diff --git a/app/users/__init__.py b/app/users/__init__.py index b3492a37..d305e242 100644 --- a/app/users/__init__.py +++ b/app/users/__init__.py @@ -15,4 +15,4 @@ def before_request(): pass -from . import events, json_routes, routes, settings +from . import cli, events, json_routes, routes, settings diff --git a/app/users/cli.py b/app/users/cli.py new file mode 100644 index 00000000..6aebca47 --- /dev/null +++ b/app/users/cli.py @@ -0,0 +1,14 @@ +from app.models import User +import os +import shutil +from app import db +from . import bp + + +@bp.cli.command('reset') +def reset(): + ''' Reset terms of use accept ''' + for user in [x for x in User.query.all() if x.terms_of_use_accepted]: + print(f'Resetting user {user.username}') + user.terms_of_use_accepted = False + db.session.commit()