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
This commit is contained in:
Matthias Portzel 2022-03-29 13:27:49 -04:00
parent 4c2251a460
commit 6408c3db55
2 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,6 @@
}
});
const mediaInput = document.getElementById("id_media");
const mediaAlt = document.getElementById("id_media_alt");
const clearCheckbox = document.getElementById("media-clear_id");

View File

@ -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