Commit 13d3358f authored by Auri's avatar Auri

Credits: affiliation -> type

parent 40567d3b
Pipeline #2823 failed with stages
in 29 seconds
......@@ -9,9 +9,9 @@ def populate_track_credit(apps, schema_editor):
TrackCredit = apps.get_model("music", "TrackCredit")
Track = apps.get_model("music", "Track")
tracks = Track.objects.values('artist__id', 'id').iterator()
tracks = Track.objects.values("artist__id", "id").iterator()
credits = [
TrackCredit(artist_id=track['artist__id'], track_id=track['id'], credit="main")
TrackCredit(artist_id=track["artist__id"], track_id=track["id"], type="main")
for track in tracks
]
TrackCredit.objects.bulk_create(credits)
......@@ -32,14 +32,14 @@ class Migration(migrations.Migration):
name="TrackCredit",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("affiliation", models.CharField(choices=[("main", "Main"), ("featured", "Featured"), ("composer", "Composer"), ("conductor", "Conductor"), ("compiler", "Compiler"), ("remixer", "Remixer"), ("producer", "Producer")], default="main", max_length=30)),
("type", models.CharField(choices=[("main", "Main"), ("featured", "Featured"), ("composer", "Composer"), ("conductor", "Conductor"), ("compiler", "Compiler"), ("remixer", "Remixer"), ("producer", "Producer")], default="main", max_length=30)),
("artist", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="credits", to="music.Artist")),
("track", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="credits", to="music.Track")),
],
),
migrations.AlterUniqueTogether(
name='trackcredit',
unique_together={('artist', 'track', 'affiliation')},
name="trackcredit",
unique_together={("artist", "track", "type")},
),
migrations.RunPython(populate_track_credit, rewind),
]
......@@ -644,12 +644,12 @@ class Credit:
class TrackCredit(models.Model):
artist = models.ForeignKey(Artist, related_name="credits", on_delete=models.CASCADE)
track = models.ForeignKey(Track, related_name="credits", on_delete=models.CASCADE)
affiliation = models.CharField(
type = models.CharField(
max_length=30, default=Credit.MAIN, choices=Credit._CHOICES
)
class Meta:
unique_together = (('artist', 'track', 'affiliation'),)
unique_together = (("artist", "track", "type"),)
TRACK_FILE_IMPORT_STATUS_CHOICES = (
......
......@@ -82,7 +82,7 @@ class ArtistCreditSerializer(serializers.ModelSerializer):
class Meta:
model = models.TrackCredit
fields = ("artist", "affiliation")
fields = ("artist", "type")
class AlbumTrackSerializer(serializers.ModelSerializer):
......
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