Change related names to something more helpful.

This commit is contained in:
Josh W 2020-03-10 14:50:53 -04:00
parent 704a792e49
commit 2fdcb38aa8
2 changed files with 25 additions and 24 deletions

View file

@ -1,4 +1,4 @@
# Generated by Django 2.0.3 on 2018-03-30 15:24
# Generated by Django 3.0.3 on 2020-03-10 14:19
from django.conf import settings
import django.core.validators
@ -11,8 +11,8 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('radio', '0005_replaygain_data'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('radio', '0002_naming_and_sorting'),
]
operations = [
@ -25,21 +25,7 @@ class Migration(migrations.Migration):
('disabled_reason', models.TextField(blank=True, verbose_name='reason for disabling')),
('created_date', models.DateTimeField(auto_now_add=True, verbose_name='added on')),
('modified_date', models.DateTimeField(auto_now=True, verbose_name='last modified')),
('favorites', models.ManyToManyField(related_name='song_favorites', to='radio.Song')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Rating',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_date', models.DateTimeField(auto_now_add=True, verbose_name='added on')),
('modified_date', models.DateTimeField(auto_now=True, verbose_name='last modified')),
('value', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(5)], verbose_name='song rating')),
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rating_profile', to='profiles.RadioProfile')),
('song', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='radio.Song')),
('favorites', models.ManyToManyField(related_name='favorited_by', to='radio.Song')),
],
options={
'abstract': False,
@ -57,22 +43,36 @@ class Migration(migrations.Migration):
('song', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='radio.Song')),
],
options={
'ordering': ['-created_date'],
'ordering': ['-queued_at', '-created_date'],
},
),
migrations.CreateModel(
name='Rating',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_date', models.DateTimeField(auto_now_add=True, verbose_name='added on')),
('modified_date', models.DateTimeField(auto_now=True, verbose_name='last modified')),
('value', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(5)], verbose_name='song rating')),
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rating_profile', to='profiles.RadioProfile')),
('song', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='radio.Song')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='radioprofile',
name='ratings',
field=models.ManyToManyField(related_name='song_ratings', through='profiles.Rating', to='radio.Song'),
field=models.ManyToManyField(related_name='ratings', through='profiles.Rating', to='radio.Song'),
),
migrations.AddField(
model_name='radioprofile',
name='song_requests',
field=models.ManyToManyField(related_name='song_requests', through='profiles.SongRequest', to='radio.Song'),
field=models.ManyToManyField(related_name='request_history', through='profiles.SongRequest', to='radio.Song'),
),
migrations.AddField(
model_name='radioprofile',
name='user',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL),
),
]

View file

@ -18,14 +18,15 @@ radio_settings = global_preferences_registry.manager()
class RadioProfile(Disableable, Timestampable, models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='profile',
null=True,
blank=True)
favorites = models.ManyToManyField(Song, related_name='song_favorites')
favorites = models.ManyToManyField(Song, related_name='favorited_by')
ratings = models.ManyToManyField(Song,
related_name='song_ratings',
related_name='ratings',
through='Rating')
song_requests = models.ManyToManyField(Song,
related_name='song_requests',
related_name='request_history',
through='SongRequest')
def disable(self, reason=''):