Commit 1af95e39 authored by fred's avatar fred

add uploader info to tracks

parent ef0f3886
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('nonstop', '0007_auto_20171003_1022'),
]
operations = [
migrations.AddField(
model_name='track',
name='uploader',
field=models.ForeignKey(to=settings.AUTH_USER_MODEL, null=True),
),
]
...@@ -2,6 +2,7 @@ import os ...@@ -2,6 +2,7 @@ import os
import mutagen import mutagen
from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
...@@ -57,6 +58,7 @@ class Track(models.Model): ...@@ -57,6 +58,7 @@ class Track(models.Model):
nonstop_zones = models.ManyToManyField('emissions.Nonstop', blank=True) nonstop_zones = models.ManyToManyField('emissions.Nonstop', blank=True)
creation_timestamp = models.DateTimeField(auto_now_add=True, null=True) creation_timestamp = models.DateTimeField(auto_now_add=True, null=True)
uploader = models.ForeignKey(settings.AUTH_USER_MODEL, null=True)
class Meta: class Meta:
ordering = ['creation_timestamp'] ordering = ['creation_timestamp']
......
...@@ -206,7 +206,8 @@ class UploadTracksView(FormView): ...@@ -206,7 +206,8 @@ class UploadTracksView(FormView):
nonstop_file = NonstopFile() nonstop_file = NonstopFile()
nonstop_file.set_track_filepath(filepath) nonstop_file.set_track_filepath(filepath)
artist, created = Artist.objects.get_or_create(name=artist_name) artist, created = Artist.objects.get_or_create(name=artist_name)
track, created = Track.objects.get_or_create(title=track_title, artist=artist) track, created = Track.objects.get_or_create(title=track_title, artist=artist,
defaults={'uploader': self.request.user})
nonstop_file.track = track nonstop_file.track = track
nonstop_file.save() nonstop_file.save()
nonstop_file.track.sync_nonstop_zones() nonstop_file.track.sync_nonstop_zones()
......
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