Fix deleting user (deleting shelfs and so on failed before)

This commit is contained in:
Ozzie Isaacs 2021-07-23 20:03:20 +02:00
parent 3b81ea37f4
commit 9a8c342e61

View File

@ -1370,11 +1370,11 @@ def _delete_user(content):
if content.name != "Guest":
# Delete all books in shelfs belonging to user, all shelfs of user, downloadstat of user, read status
# and user itself
ub.session.query(ub.ReadBook).filter(ub.User.id == ub.ReadBook.user_id).delete()
ub.session.query(ub.Downloads).filter(ub.User.id == ub.Downloads.user_id).delete()
for us in ub.session.query(ub.Shelf).filter(ub.User.id == ub.Shelf.user_id):
ub.session.query(ub.ReadBook).filter(content.id == ub.ReadBook.user_id).delete()
ub.session.query(ub.Downloads).filter(content.id == ub.Downloads.user_id).delete()
for us in ub.session.query(ub.Shelf).filter(content.id == ub.Shelf.user_id):
ub.session.query(ub.BookShelf).filter(us.id == ub.BookShelf.shelf).delete()
ub.session.query(ub.Shelf).filter(ub.User.id == ub.Shelf.user_id).delete()
ub.session.query(ub.Shelf).filter(content.id == ub.Shelf.user_id).delete()
ub.session.query(ub.User).filter(ub.User.id == content.id).delete()
ub.session_commit()
log.info(u"User {} deleted".format(content.name))