mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
19 lines
527 B
Python
19 lines
527 B
Python
|
from .. import logger
|
||
|
from ..decorators import background
|
||
|
from ..models import User
|
||
|
import os
|
||
|
import shutil
|
||
|
|
||
|
|
||
|
@background
|
||
|
def delete_user(app, user_id):
|
||
|
logger.warning('aufgerufen')
|
||
|
with app.app_context():
|
||
|
user = User.query.get(user_id)
|
||
|
if user is None:
|
||
|
raise Exception('User {} not found!'.format(user_id))
|
||
|
logger.warning('deleting user')
|
||
|
path = os.path.join(app.config['NOPAQUE_STORAGE'], str(user.id))
|
||
|
shutil.rmtree(path, ignore_errors=True)
|
||
|
user.delete()
|