nopaque/app/settings/tasks.py

14 lines
351 B
Python
Raw Normal View History

from app import db
from app.decorators import background
from app.models import User
2020-10-26 10:17:25 +00:00
@background
def delete_user(user_id, *args, **kwargs):
with kwargs['app'].app_context():
user = User.query.get(user_id)
if user is None:
2021-12-08 13:45:05 +00:00
raise Exception(f'User {user_id} not found')
2020-10-26 10:17:25 +00:00
user.delete()
db.session.commit()