From 90806892911589a37fbb6ef23da005f87619da82 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Tue, 9 Jul 2024 11:52:24 -0400 Subject: [PATCH] feat: rename Host -> Profile model and rename references to it --- .../migrations/0110_rename_host_profile.py | 19 +++++ ...ptions_alter_profile_biography_and_more.py | 62 ++++++++++++++ .../migrations/0112_profilelink_and_more.py | 80 +++++++++++++++++++ ...contributors_alter_timeslot_playlist_id.py | 27 +++++++ program/models.py | 42 +++++----- 5 files changed, 209 insertions(+), 21 deletions(-) create mode 100644 program/migrations/0110_rename_host_profile.py create mode 100644 program/migrations/0111_alter_profile_options_alter_profile_biography_and_more.py create mode 100644 program/migrations/0112_profilelink_and_more.py create mode 100644 program/migrations/0113_alter_note_contributors_alter_timeslot_playlist_id.py diff --git a/program/migrations/0110_rename_host_profile.py b/program/migrations/0110_rename_host_profile.py new file mode 100644 index 00000000..2e1fec88 --- /dev/null +++ b/program/migrations/0110_rename_host_profile.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.13 on 2024-07-08 20:14 + +from django.conf import settings +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("program", "0109_cba_delete_userprofile"), + ] + + operations = [ + migrations.RenameModel( + old_name="Host", + new_name="Profile", + ), + ] diff --git a/program/migrations/0111_alter_profile_options_alter_profile_biography_and_more.py b/program/migrations/0111_alter_profile_options_alter_profile_biography_and_more.py new file mode 100644 index 00000000..be936897 --- /dev/null +++ b/program/migrations/0111_alter_profile_options_alter_profile_biography_and_more.py @@ -0,0 +1,62 @@ +# Generated by Django 4.2.13 on 2024-07-08 20:16 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("program", "0110_rename_host_profile"), + ] + + operations = [ + migrations.AlterModelOptions( + name="profile", + options={ + "ordering": ("name",), + "permissions": [ + ("edit__profile__biography", "Can edit biography field"), + ("edit__profile__email", "Can edit email field"), + ("edit__profile__image", "Can edit image field"), + ("edit__profile__links", "Can edit links field"), + ("edit__profile__name", "Can edit name field"), + ("edit__profile__owners", "Can edit owners field"), + ("update_profile", "Can update profile"), + ], + }, + ), + migrations.AlterField( + model_name="profile", + name="biography", + field=models.TextField(blank=True, help_text="Biography of the profile."), + ), + migrations.AlterField( + model_name="profile", + name="email", + field=models.EmailField( + blank=True, help_text="Email address of the profile.", max_length=254 + ), + ), + migrations.AlterField( + model_name="profile", + name="is_active", + field=models.BooleanField(default=True, help_text="True if the profile is active."), + ), + migrations.AlterField( + model_name="profile", + name="name", + field=models.CharField(help_text="Display name of the profile.", max_length=128), + ), + migrations.AlterField( + model_name="profile", + name="owners", + field=models.ManyToManyField( + blank=True, + help_text="User ID(s) that own this profile.", + related_name="hosts", + to=settings.AUTH_USER_MODEL, + ), + ), + ] diff --git a/program/migrations/0112_profilelink_and_more.py b/program/migrations/0112_profilelink_and_more.py new file mode 100644 index 00000000..ced033c9 --- /dev/null +++ b/program/migrations/0112_profilelink_and_more.py @@ -0,0 +1,80 @@ +# Generated by Django 4.2.13 on 2024-07-08 20:36 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("program", "0111_alter_profile_options_alter_profile_biography_and_more"), + ] + + operations = [ + migrations.CreateModel( + name="ProfileLink", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ("url", models.URLField()), + ], + options={ + "abstract": False, + }, + ), + migrations.RenameField( + model_name="radiosettings", + old_name="host_image_aspect_ratio", + new_name="profile_image_aspect_ratio", + ), + migrations.RenameField( + model_name="radiosettings", + old_name="host_image_shape", + new_name="profile_image_shape", + ), + migrations.AlterField( + model_name="profile", + name="image", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="profiles", + to="program.image", + ), + ), + migrations.AlterField( + model_name="profile", + name="owners", + field=models.ManyToManyField( + blank=True, + help_text="User ID(s) that own this profile.", + related_name="profiles", + to=settings.AUTH_USER_MODEL, + ), + ), + migrations.DeleteModel( + name="HostLink", + ), + migrations.AddField( + model_name="profilelink", + name="profile", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="links", + to="program.profile", + ), + ), + migrations.AddField( + model_name="profilelink", + name="type", + field=models.ForeignKey( + default=1, on_delete=django.db.models.deletion.CASCADE, to="program.linktype" + ), + ), + ] diff --git a/program/migrations/0113_alter_note_contributors_alter_timeslot_playlist_id.py b/program/migrations/0113_alter_note_contributors_alter_timeslot_playlist_id.py new file mode 100644 index 00000000..aa1b25d2 --- /dev/null +++ b/program/migrations/0113_alter_note_contributors_alter_timeslot_playlist_id.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.13 on 2024-07-09 00:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("program", "0112_profilelink_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="note", + name="contributors", + field=models.ManyToManyField( + help_text="Profile IDs that contributed to this episode.", + related_name="notes", + to="program.profile", + ), + ), + migrations.AlterField( + model_name="timeslot", + name="playlist_id", + field=models.IntegerField(help_text="Playlist ID of this timeslot.", null=True), + ), + ] diff --git a/program/models.py b/program/models.py index 611f8712..fe6ba333 100644 --- a/program/models.py +++ b/program/models.py @@ -164,16 +164,16 @@ class Image(models.Model): return self.image.thumbnail[f"{width}x{height}"].url -class Host(models.Model): - biography = models.TextField(blank=True, help_text="Biography of the host.") +class Profile(models.Model): + biography = models.TextField(blank=True, help_text="Biography of the profile.") created_at = models.DateTimeField(auto_now_add=True) created_by = models.CharField(max_length=150) - email = models.EmailField(blank=True, help_text="Email address of the host.") - image = models.ForeignKey(Image, null=True, on_delete=models.CASCADE, related_name="hosts") - is_active = models.BooleanField(default=True, help_text="True if host is active.") - name = models.CharField(max_length=128, help_text="Display name of the host.") + email = models.EmailField(blank=True, help_text="Email address of the profile.") + image = models.ForeignKey(Image, null=True, on_delete=models.CASCADE, related_name="profiles") + is_active = models.BooleanField(default=True, help_text="True if the profile is active.") + name = models.CharField(max_length=128, help_text="Display name of the profile.") owners = models.ManyToManyField( - User, blank=True, related_name="hosts", help_text="User ID(s) identifying this host." + User, blank=True, related_name="profiles", help_text="User ID(s) that own this profile." ) updated_at = models.DateTimeField(auto_now=True, blank=True, null=True) updated_by = models.CharField(blank=True, default="", max_length=150) @@ -181,14 +181,14 @@ class Host(models.Model): class Meta: ordering = ("name",) permissions = [ - ("edit__host__biography", "Can edit biography field"), - ("edit__host__email", "Can edit email field"), - ("edit__host__image", "Can edit image field"), - ("edit__host__links", "Can edit links field"), - ("edit__host__name", "Can edit name field"), - ("edit__host__owners", "Can edit owners field"), + ("edit__profile__biography", "Can edit biography field"), + ("edit__profile__email", "Can edit email field"), + ("edit__profile__image", "Can edit image field"), + ("edit__profile__links", "Can edit links field"), + ("edit__profile__name", "Can edit name field"), + ("edit__profile__owners", "Can edit owners field"), # overrides ownership - ("update_host", "Can update host"), + ("update_profile", "Can update profile"), ] def __str__(self): @@ -217,8 +217,8 @@ class Link(models.Model): return self.url -class HostLink(Link): - host = models.ForeignKey(Host, on_delete=models.CASCADE, related_name="links") +class ProfileLink(Link): + profile = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name="links") class ShowManager(models.Manager): @@ -239,7 +239,7 @@ class Show(models.Model): funding_category = models.ForeignKey( FundingCategory, blank=True, null=True, on_delete=models.CASCADE, related_name="shows" ) - hosts = models.ManyToManyField(Host, blank=True, related_name="shows") + hosts = models.ManyToManyField(Profile, blank=True, related_name="shows") image = models.ForeignKey(Image, null=True, on_delete=models.CASCADE, related_name="shows") internal_note = models.TextField(blank=True, help_text="Internal note for this show.") is_active = models.BooleanField(default=True, help_text="True if this show is active.") @@ -441,7 +441,7 @@ 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_id = models.IntegerField(null=True, help_text="Playlist ID of this timeslot.") repetition_of = models.ForeignKey( "self", blank=True, null=True, on_delete=models.CASCADE, related_name="repetitions" ) @@ -486,7 +486,7 @@ class Note(models.Model): cba_id = models.IntegerField(blank=True, null=True, help_text="CBA entry ID.") content = models.TextField(help_text="Textual content of the note.") contributors = models.ManyToManyField( - Host, related_name="notes", help_text="`Host` IDs contributing to this note." + Profile, related_name="notes", help_text="Profile IDs that contributed to this episode." ) created_at = models.DateTimeField(auto_now_add=True) created_by = models.CharField(max_length=150) @@ -647,8 +647,6 @@ class RadioSettings(models.Model): fallback_show = models.ForeignKey( Show, blank=True, null=True, on_delete=models.CASCADE, related_name="+" ) - host_image_aspect_ratio = ImageAspectRadioField(default="1:1") - host_image_shape = ImageShapeField(default="round") line_in_channels = models.JSONField( blank=True, default=dict, @@ -666,6 +664,8 @@ class RadioSettings(models.Model): help_text="JSON key/value pairs", validators=[validate_fallback_pools], ) + profile_image_aspect_ratio = ImageAspectRadioField(default="1:1") + profile_image_shape = ImageShapeField(default="round") show_image_aspect_ratio = ImageAspectRadioField(default="16:9") show_image_shape = ImageShapeField(default="rect") show_logo_aspect_ratio = ImageAspectRadioField(default="1:1") -- GitLab