From 9a8c342e614f21033a6d6e4953a17e3c4f83e7d6 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Fri, 23 Jul 2021 20:03:20 +0200 Subject: [PATCH] Fix deleting user (deleting shelfs and so on failed before) --- cps/admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 97b41165..cd30f7d4 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -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))