From 96301f6e310933dcd9e3fd777a5863a0deb26933 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 05:50:53 +0000 Subject: [PATCH 1/2] Initial plan From 4f38f530a68c1bef5c8d199eaabe7bde6b900117 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 05:56:29 +0000 Subject: [PATCH 2/2] Fix: Add duplicate name check in rename_image to prevent 500 errors Co-authored-by: maubreville <10051592+maubreville@users.noreply.github.com> --- exact/exact/images/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exact/exact/images/views.py b/exact/exact/images/views.py index 7eff24b9..9e8e81ca 100644 --- a/exact/exact/images/views.py +++ b/exact/exact/images/views.py @@ -1716,6 +1716,13 @@ def rename_image(request, imageset_id): if 'edit_set' in imageset.get_perms(request.user): + # Check if an image with the new name already exists in the imageset + existing_image = Image.objects.filter(Q(name=newName)|Q(filename=newstem+filenameext), + image_set=imageset).exclude(id=image.id).first() + if existing_image is not None: + # Image with this name already exists, redirect without changes + return redirect(reverse('images:view_imageset', args=(imageset_id,))) + if os.path.exists(os.path.join(imageset.root_path(),image.name)): os.rename(os.path.join(imageset.root_path(),image.name), os.path.join(imageset.root_path(),newName))