mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-10 08:17:59 -05:00
Fix issue where user old photo might not be deleted from filesystem
Fix issue where user old photo might not be deleted from filesystem
This commit is contained in:
@@ -340,8 +340,8 @@ def edit_user(user_id: int, user: users_schema.UserRead, db: Session):
|
||||
|
||||
height_before = db_user.height
|
||||
|
||||
# If the user photo path is different, delete the user photo in the filesystem
|
||||
if db_user.photo_path != user.photo_path:
|
||||
# Check if the photo_path is being updated
|
||||
if user.photo_path:
|
||||
# Delete the user photo in the filesystem
|
||||
users_utils.delete_user_photo_filesystem(db_user.id)
|
||||
|
||||
@@ -388,9 +388,7 @@ def edit_user(user_id: int, user: users_schema.UserRead, db: Session):
|
||||
) from err
|
||||
|
||||
|
||||
def approve_user(
|
||||
user_id: int, db: Session
|
||||
):
|
||||
def approve_user(user_id: int, db: Session):
|
||||
"""
|
||||
Approve a user by ID.
|
||||
|
||||
|
||||
@@ -698,6 +698,11 @@ async function submitEditUserForm() {
|
||||
photo_path: newEditUserPhotoPath.value,
|
||||
active: newEditUserActive.value
|
||||
}
|
||||
if (props.action === 'profile') {
|
||||
await profile.editProfile(data)
|
||||
} else {
|
||||
await users.editUser(data.id, data)
|
||||
}
|
||||
if (newEditUserPhotoFile.value) {
|
||||
try {
|
||||
if (props.action === 'profile') {
|
||||
@@ -711,11 +716,6 @@ async function submitEditUserForm() {
|
||||
)
|
||||
}
|
||||
}
|
||||
if (props.action === 'profile') {
|
||||
await profile.editProfile(data)
|
||||
} else {
|
||||
await users.editUser(data.id, data)
|
||||
}
|
||||
if (props.action === 'edit') {
|
||||
emit('editedUser', data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user