Fixed #44: now bind track file to import job

This commit is contained in:
Eliot Berriot 2017-12-14 23:06:21 +01:00
parent a08bf51216
commit e90e9dc7aa
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
14 changed files with 181 additions and 16 deletions

View file

@ -393,6 +393,8 @@ class ImportBatch(models.Model):
class ImportJob(models.Model):
batch = models.ForeignKey(ImportBatch, related_name='jobs')
track_file = models.ForeignKey(
TrackFile, related_name='jobs', null=True, blank=True)
source = models.URLField()
mbid = models.UUIDField(editable=False)
STATUS_CHOICES = (
@ -413,10 +415,12 @@ class ImportJob(models.Model):
elif track.files.count() > 0:
return
track_file = track_file or TrackFile(track=track, source=self.source)
track_file = track_file or TrackFile(
track=track, source=self.source)
track_file.download_file()
track_file.save()
self.status = 'finished'
self.track_file = track_file
self.save()
return track.pk