From 6408c3db5560e7dfc0de2fb198ec7254f8d75340 Mon Sep 17 00:00:00 2001 From: Matthias Portzel Date: Tue, 29 Mar 2022 13:27:49 -0400 Subject: [PATCH] Fix bug that prevented editing alt-text * If there was already an uploaded file, it doesn't get re-uploaded when editing, and doesn't show up in request.FILES. The file name is still in thought.media so we can use that to tell if there's a image and if we should allow media_alt --- main/templates/whispermaphone/post.html | 1 - main/views.py | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/templates/whispermaphone/post.html b/main/templates/whispermaphone/post.html index 951336f..b20a512 100644 --- a/main/templates/whispermaphone/post.html +++ b/main/templates/whispermaphone/post.html @@ -88,7 +88,6 @@ } }); - const mediaInput = document.getElementById("id_media"); const mediaAlt = document.getElementById("id_media_alt"); const clearCheckbox = document.getElementById("media-clear_id"); diff --git a/main/views.py b/main/views.py index 7119ef1..f99f994 100644 --- a/main/views.py +++ b/main/views.py @@ -143,8 +143,9 @@ def post(request): ], check=True) os.remove(os.path.join(settings.MEDIA_ROOT, f"{thought.uuid}.m4a")) # Remove the original file thought.media.name = f"{thought.uuid}.aac" # Update the file in the DB - else: - # We need to make sure that if we remove an image, the alt text is removed with it + + # We need to make sure that if we remove an image, the alt text is removed with it + if not thought.media: thought.media_alt = "" # Save for real