nopaque/web/app/profile/tasks.py

14 lines
354 B
Python
Raw Normal View History

2020-07-10 09:36:54 +00:00
from .. import db
from ..decorators import background
from ..models import User
@background
def delete_user(user_id, *args, **kwargs):
2020-07-10 09:36:54 +00:00
with kwargs['app'].app_context():
user = User.query.get(user_id)
if user is None:
2020-07-10 09:36:54 +00:00
raise Exception('User {} not found'.format(user_id))
user.delete()
2020-07-10 09:36:54 +00:00
db.session.commit()