Commit 6b7fda14 authored by fred's avatar fred

do not create a duplicated nonstop file object on duplicate upload

parent f0ea5ae9
......@@ -217,12 +217,15 @@ class UploadTracksView(FormView):
artist, created = Artist.objects.get_or_create(name=artist_name)
track, created = Track.objects.get_or_create(title=track_title, artist=artist,
defaults={'uploader': self.request.user})
nonstop_file.track = track
nonstop_file.save()
if created:
nonstop_file.track = track
nonstop_file.save()
else:
pass # do not create a duplicated nonstop file object
if request.POST.get('nonstop_zone'):
track.nonstop_zones.add(
Nonstop.objects.get(id=request.POST.get('nonstop_zone')))
nonstop_file.track.sync_nonstop_zones()
track.sync_nonstop_zones()
messages.info(self.request, '%d new track(s)' % len(tracks))
return self.form_valid(form)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment