Add start of a rating model for tracks
This commit is contained in:
25
vrobbler/apps/music/migrations/0004_track_thumbs.py
Normal file
25
vrobbler/apps/music/migrations/0004_track_thumbs.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 4.1.5 on 2023-01-09 16:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('music', '0003_album_uuid_artist_uuid_track_uuid'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='track',
|
||||||
|
name='thumbs',
|
||||||
|
field=models.IntegerField(
|
||||||
|
choices=[
|
||||||
|
(-1, 'Thumbs down'),
|
||||||
|
(0, 'No opinion'),
|
||||||
|
(1, 'Thumbs up'),
|
||||||
|
],
|
||||||
|
default=0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -42,6 +42,11 @@ class Artist(TimeStampedModel):
|
|||||||
|
|
||||||
|
|
||||||
class Track(TimeStampedModel):
|
class Track(TimeStampedModel):
|
||||||
|
class Opinion(models.IntegerChoices):
|
||||||
|
DOWN = -1, 'Thumbs down'
|
||||||
|
NEUTRAL = 0, 'No opinion'
|
||||||
|
UP = 1, 'Thumbs up'
|
||||||
|
|
||||||
uuid = models.UUIDField(default=uuid4, editable=False, **BNULL)
|
uuid = models.UUIDField(default=uuid4, editable=False, **BNULL)
|
||||||
title = models.CharField(max_length=255, **BNULL)
|
title = models.CharField(max_length=255, **BNULL)
|
||||||
artist = models.ForeignKey(Artist, on_delete=models.DO_NOTHING)
|
artist = models.ForeignKey(Artist, on_delete=models.DO_NOTHING)
|
||||||
@ -49,6 +54,7 @@ class Track(TimeStampedModel):
|
|||||||
musicbrainz_id = models.CharField(max_length=255, **BNULL)
|
musicbrainz_id = models.CharField(max_length=255, **BNULL)
|
||||||
run_time = models.CharField(max_length=8, **BNULL)
|
run_time = models.CharField(max_length=8, **BNULL)
|
||||||
run_time_ticks = models.PositiveBigIntegerField(**BNULL)
|
run_time_ticks = models.PositiveBigIntegerField(**BNULL)
|
||||||
|
thumbs = models.IntegerField(default=Opinion.NEUTRAL, choices=Opinion.choices)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.title} by {self.artist}"
|
return f"{self.title} by {self.artist}"
|
||||||
|
|||||||
Reference in New Issue
Block a user