From 013a94d1e9166295c173de842f7a721f3a43392a Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 19 Jan 2021 10:47:48 +0100 Subject: [PATCH] fix user delete profile pic --- app/api/views/user_info.py | 6 +++--- tests/test_email_utils.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/views/user_info.py b/app/api/views/user_info.py index 380f2634..1ac69585 100644 --- a/app/api/views/user_info.py +++ b/app/api/views/user_info.py @@ -55,12 +55,12 @@ def update_user_info(): if data["profile_picture"] is None: if user.profile_picture_id: file = user.profile_picture + user.profile_picture_id = None + db.session.flush() if file: File.delete(file.id) s3.delete(file.path) - - user.profile_picture_id = None - db.session.flush() + db.session.flush() else: raw_data = base64.decodebytes(data["profile_picture"].encode()) file_path = random_string(30) diff --git a/tests/test_email_utils.py b/tests/test_email_utils.py index 0ad3c8d0..5c841093 100644 --- a/tests/test_email_utils.py +++ b/tests/test_email_utils.py @@ -30,6 +30,7 @@ from app.email_utils import ( ) from app.extensions import db from app.models import User, CustomDomain, Alias, Contact, EmailLog + # flake8: noqa: E101, W191 from tests.utils import login