Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions exact/exact/images/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down