From d9dc2176d17a6ec40375694cba715981eea860c8 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Tue, 29 Oct 2024 17:35:44 -0400 Subject: [PATCH] feat: replace playlist_id with playlist --- ..._timeslot_playlist_id_timeslot_playlist.py | 30 +++++++++++++++++++ program/models.py | 9 +++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 program/migrations/0122_remove_timeslot_playlist_id_timeslot_playlist.py diff --git a/program/migrations/0122_remove_timeslot_playlist_id_timeslot_playlist.py b/program/migrations/0122_remove_timeslot_playlist_id_timeslot_playlist.py new file mode 100644 index 00000000..11cbc555 --- /dev/null +++ b/program/migrations/0122_remove_timeslot_playlist_id_timeslot_playlist.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.16 on 2024-10-29 21:34 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("program", "0121_remove_schedule_default_playlist_id_and_more"), + ] + + operations = [ + migrations.RemoveField( + model_name="timeslot", + name="playlist_id", + ), + migrations.AddField( + model_name="timeslot", + name="playlist", + field=models.ForeignKey( + blank=True, + help_text="Playlist for this timeslot.", + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="+", + to="program.playlist", + ), + ), + ] diff --git a/program/models.py b/program/models.py index ec4ce5fc..08aa6875 100644 --- a/program/models.py +++ b/program/models.py @@ -459,7 +459,14 @@ class Schedule(models.Model): class TimeSlot(models.Model): end = models.DateTimeField() memo = models.TextField(blank=True, help_text="Memo for this timeslot.") - playlist_id = models.IntegerField(null=True, help_text="Playlist ID of this timeslot.") + playlist = models.ForeignKey( + "Playlist", + blank=True, + help_text="Playlist for this timeslot.", + null=True, + on_delete=models.SET_NULL, + related_name="+", + ) repetition_of = models.ForeignKey( "self", blank=True, null=True, on_delete=models.SET_NULL, related_name="repetitions" ) -- GitLab