Skip to content

Commit

Permalink
enable upload of diff. sounds with same filename
Browse files Browse the repository at this point in the history
  • Loading branch information
quimmrc committed Dec 16, 2024
1 parent 534d66e commit 712a43e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,18 @@ def upload(request, no_flash=False):
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
submitted_files = request.FILES.getlist('files')
files_names = list()
for file_ in submitted_files:
#check for duplicated names and add an identifier, otherwise, different files with the same
#name will be overwritten in the description queue
if file_.name in files_names:
name_counter = files_names.count(file_.name)
files_names.append(file_.name)
name, extension = os.path.splitext(file_.name)
file_.name = "%s(%d)%s" % (name, name_counter, extension)
else:
files_names.append(file_.name)

if handle_uploaded_file(request.user.id, file_):
uploaded_file = file_
successes += 1
Expand Down

0 comments on commit 712a43e

Please sign in to comment.