Skip to content

Commit

Permalink
improve variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
quimmrc committed Dec 18, 2024
1 parent 712a43e commit 043373c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,17 +1284,17 @@ 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()
duplicated_filenames = 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)
if file_.name in duplicated_filenames:
name_counter = duplicated_filenames.count(file_.name)
duplicated_filenames.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)
duplicated_filenames.append(file_.name)

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

0 comments on commit 043373c

Please sign in to comment.