Now store source AP track file on track_file
This commit is contained in:
parent
04d710e690
commit
8db832f03b
|
@ -1,31 +0,0 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-03 19:21
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('federation', '0002_auto_20180403_1620'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Follow',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
|
||||
('creation_date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('last_modification_date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('actor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emitted_follows', to='federation.Actor')),
|
||||
('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='received_follows', to='federation.Actor')),
|
||||
],
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='follow',
|
||||
unique_together={('actor', 'target')},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,48 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-06 13:19
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('federation', '0002_auto_20180403_1620'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Follow',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
|
||||
('creation_date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('modification_date', models.DateTimeField(auto_now=True)),
|
||||
('actor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emitted_follows', to='federation.Actor')),
|
||||
('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='received_follows', to='federation.Actor')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='FollowRequest',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
|
||||
('creation_date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('modification_date', models.DateTimeField(auto_now=True)),
|
||||
('approved', models.NullBooleanField(default=None)),
|
||||
('actor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emmited_follow_requests', to='federation.Actor')),
|
||||
('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='received_follow_requests', to='federation.Actor')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='actor',
|
||||
name='followers',
|
||||
field=models.ManyToManyField(related_name='following', through='federation.Follow', to='federation.Actor'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='follow',
|
||||
unique_together={('actor', 'target')},
|
||||
),
|
||||
]
|
|
@ -1,28 +0,0 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-04 17:11
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('federation', '0003_auto_20180403_1921'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='FollowRequest',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
|
||||
('creation_date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('last_modification_date', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('approved', models.NullBooleanField(default=None)),
|
||||
('actor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='emmited_follow_requests', to='federation.Actor')),
|
||||
('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='received_follow_requests', to='federation.Actor')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -1,18 +0,0 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-05 16:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('federation', '0004_followrequest'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='actor',
|
||||
name='followers',
|
||||
field=models.ManyToManyField(related_name='following', through='federation.Follow', to='federation.Actor'),
|
||||
),
|
||||
]
|
|
@ -106,8 +106,8 @@ class Follow(models.Model):
|
|||
on_delete=models.CASCADE,
|
||||
)
|
||||
creation_date = models.DateTimeField(default=timezone.now)
|
||||
last_modification_date = models.DateTimeField(
|
||||
default=timezone.now)
|
||||
modification_date = models.DateTimeField(
|
||||
auto_now=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ['actor', 'target']
|
||||
|
@ -129,8 +129,8 @@ class FollowRequest(models.Model):
|
|||
on_delete=models.CASCADE,
|
||||
)
|
||||
creation_date = models.DateTimeField(default=timezone.now)
|
||||
last_modification_date = models.DateTimeField(
|
||||
default=timezone.now)
|
||||
modification_date = models.DateTimeField(
|
||||
auto_now=True)
|
||||
approved = models.NullBooleanField(default=None)
|
||||
|
||||
def approve(self):
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-05 18:30
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('federation', '0005_actor_followers'),
|
||||
('music', '0022_importbatch_import_request'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='importbatch',
|
||||
name='federation_actor',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='import_batches', to='federation.Actor'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importbatch',
|
||||
name='federation_source',
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importjob',
|
||||
name='federation_source',
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importjob',
|
||||
name='metadata',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(default={}),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='importbatch',
|
||||
name='source',
|
||||
field=models.CharField(choices=[('api', 'api'), ('shell', 'shell'), ('federation', 'federation')], default='api', max_length=30),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='importbatch',
|
||||
name='submitted_by',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='imports', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,104 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-06 13:19
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('federation', '0003_auto_20180406_1319'),
|
||||
('music', '0022_importbatch_import_request'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='album',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='artist',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importbatch',
|
||||
name='federation_actor',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='import_batches', to='federation.Actor'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importbatch',
|
||||
name='federation_source',
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importbatch',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importjob',
|
||||
name='federation_source',
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importjob',
|
||||
name='metadata',
|
||||
field=django.contrib.postgres.fields.jsonb.JSONField(default={}),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importjob',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='lyrics',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='track',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='trackfile',
|
||||
name='creation_date',
|
||||
field=models.DateTimeField(default=django.utils.timezone.now),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='trackfile',
|
||||
name='federation_source',
|
||||
field=models.URLField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='trackfile',
|
||||
name='modification_date',
|
||||
field=models.DateTimeField(auto_now=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='trackfile',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='work',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='importbatch',
|
||||
name='source',
|
||||
field=models.CharField(choices=[('api', 'api'), ('shell', 'shell'), ('federation', 'federation')], default='api', max_length=30),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='importbatch',
|
||||
name='submitted_by',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='imports', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
|
@ -1,54 +0,0 @@
|
|||
# Generated by Django 2.0.3 on 2018-04-06 11:15
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('music', '0023_auto_20180405_1830'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='album',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='artist',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importbatch',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='importjob',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='lyrics',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='track',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='trackfile',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='work',
|
||||
name='uuid',
|
||||
field=models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
|
||||
),
|
||||
]
|
|
@ -414,6 +414,12 @@ class TrackFile(models.Model):
|
|||
Track, related_name='files', on_delete=models.CASCADE)
|
||||
audio_file = models.FileField(upload_to='tracks/%Y/%m/%d', max_length=255)
|
||||
source = models.URLField(null=True, blank=True)
|
||||
creation_date = models.DateTimeField(default=timezone.now)
|
||||
modification_date = models.DateTimeField(auto_now=True)
|
||||
|
||||
# points to the URL of the original trackfile ActivityPub Object
|
||||
federation_source = models.URLField(null=True, blank=True)
|
||||
|
||||
duration = models.IntegerField(null=True, blank=True)
|
||||
acoustid_track_id = models.UUIDField(null=True, blank=True)
|
||||
mimetype = models.CharField(null=True, blank=True, max_length=200)
|
||||
|
|
|
@ -102,6 +102,7 @@ def _do_import(import_job, replace, use_acoustid=True):
|
|||
track_file = track_file or models.TrackFile(
|
||||
track=track, source=import_job.source)
|
||||
track_file.acoustid_track_id = acoustid_track_id
|
||||
track_file.federation_source = import_job.federation_source
|
||||
if from_file:
|
||||
track_file.audio_file = ContentFile(import_job.audio_file.read())
|
||||
track_file.audio_file.name = import_job.audio_file.name
|
||||
|
|
|
@ -62,6 +62,7 @@ def test_import_job_from_federation_no_musicbrainz(factories):
|
|||
|
||||
tf = job.track_file
|
||||
assert tf.source == job.source
|
||||
assert tf.federation_source == job.federation_source
|
||||
assert tf.track.title == 'Ping'
|
||||
assert tf.track.artist.name == 'Hello'
|
||||
assert tf.track.album.title == 'World'
|
||||
|
@ -84,6 +85,7 @@ def test_import_job_from_federation_musicbrainz_recording(factories, mocker):
|
|||
|
||||
tf = job.track_file
|
||||
assert tf.source == job.source
|
||||
assert tf.federation_source == job.federation_source
|
||||
assert tf.track == t
|
||||
track_from_api.assert_called_once_with(
|
||||
mbid=tasks.get_mbid(job.metadata['recording'], 'recording'))
|
||||
|
@ -105,6 +107,7 @@ def test_import_job_from_federation_musicbrainz_release(factories, mocker):
|
|||
job.refresh_from_db()
|
||||
|
||||
tf = job.track_file
|
||||
assert tf.federation_source == job.federation_source
|
||||
assert tf.source == job.source
|
||||
assert tf.track.title == 'Ping'
|
||||
assert tf.track.artist == a.artist
|
||||
|
@ -131,6 +134,7 @@ def test_import_job_from_federation_musicbrainz_artist(factories, mocker):
|
|||
|
||||
tf = job.track_file
|
||||
assert tf.source == job.source
|
||||
assert tf.federation_source == job.federation_source
|
||||
assert tf.track.title == 'Ping'
|
||||
assert tf.track.artist == a
|
||||
assert tf.track.album.artist == a
|
||||
|
|
Loading…
Reference in New Issue