From af64c5ccf9fe7525edd5b01a4ad5b0ba0519afa1 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Mon, 3 Jun 2024 12:46:54 -0400
Subject: [PATCH] feat: add aspect ratio and shape to host/note/show images &
 show logo

---
 ...ttings_host_image_aspect_ratio_and_more.py | 70 +++++++++++++++++++
 program/models.py                             | 30 ++++++++
 2 files changed, 100 insertions(+)
 create mode 100644 program/migrations/0091_radiosettings_host_image_aspect_ratio_and_more.py

diff --git a/program/migrations/0091_radiosettings_host_image_aspect_ratio_and_more.py b/program/migrations/0091_radiosettings_host_image_aspect_ratio_and_more.py
new file mode 100644
index 00000000..c6032dfc
--- /dev/null
+++ b/program/migrations/0091_radiosettings_host_image_aspect_ratio_and_more.py
@@ -0,0 +1,70 @@
+# Generated by Django 4.2.13 on 2024-06-03 16:43
+
+import program.models
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("program", "0090_alter_playlist_options"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="radiosettings",
+            name="host_image_aspect_ratio",
+            field=program.models.ImageAspectRadioField(
+                choices=[("1:1", "1:1"), ("16:9", "16:9")], default="1:1", max_length=4
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="host_image_shape",
+            field=program.models.ImageShapeField(
+                choices=[("rect", "rect"), ("round", "round")], default="round", max_length=5
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="note_image_aspect_ratio",
+            field=program.models.ImageAspectRadioField(
+                choices=[("1:1", "1:1"), ("16:9", "16:9")], default="16:9", max_length=4
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="note_image_shape",
+            field=program.models.ImageShapeField(
+                choices=[("rect", "rect"), ("round", "round")], default="rect", max_length=5
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="show_image_aspect_ratio",
+            field=program.models.ImageAspectRadioField(
+                choices=[("1:1", "1:1"), ("16:9", "16:9")], default="16:9", max_length=4
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="show_image_shape",
+            field=program.models.ImageShapeField(
+                choices=[("rect", "rect"), ("round", "round")], default="rect", max_length=5
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="show_logo_aspect_ratio",
+            field=program.models.ImageAspectRadioField(
+                choices=[("1:1", "1:1"), ("16:9", "16:9")], default="1:1", max_length=4
+            ),
+        ),
+        migrations.AddField(
+            model_name="radiosettings",
+            name="show_logo_shape",
+            field=program.models.ImageShapeField(
+                choices=[("rect", "rect"), ("round", "round")], default="rect", max_length=5
+            ),
+        ),
+    ]
diff --git a/program/models.py b/program/models.py
index 6a58ae8d..7e1d38b6 100644
--- a/program/models.py
+++ b/program/models.py
@@ -526,13 +526,43 @@ class Playlist(models.Model):
         ]
 
 
+class ImageAspectRadioField(models.CharField):
+    def __init__(self, *args, **kwargs):
+        kwargs["choices"] = [
+            ("1:1", "1:1"),
+            ("16:9", "16:9"),
+        ]
+        kwargs["max_length"] = 4
+
+        super().__init__(*args, **kwargs)
+
+
+class ImageShapeField(models.CharField):
+    def __init__(self, *args, **kwargs):
+        kwargs["choices"] = [
+            ("rect", "rect"),
+            ("round", "round"),
+        ]
+        kwargs["max_length"] = 5
+
+        super().__init__(*args, **kwargs)
+
+
 class RadioSettings(models.Model):
     cba_api_key = models.CharField(blank=True, max_length=64, verbose_name="CBA API key")
     cba_domains = models.JSONField(
         blank=True, default=list, help_text="JSON array of strings", verbose_name="CBA domains"
     )
     fallback_show = models.ForeignKey(Show, blank=True, null=True, on_delete=models.CASCADE)
+    host_image_aspect_ratio = ImageAspectRadioField(default="1:1")
+    host_image_shape = ImageShapeField(default="round")
     line_in_channels = models.JSONField(blank=True, default=dict, help_text="JSON key/value pairs")
+    note_image_aspect_ratio = ImageAspectRadioField(default="16:9")
+    note_image_shape = ImageShapeField(default="rect")
+    show_image_aspect_ratio = ImageAspectRadioField(default="16:9")
+    show_image_shape = ImageShapeField(default="rect")
+    show_logo_aspect_ratio = ImageAspectRadioField(default="1:1")
+    show_logo_shape = ImageShapeField(default="rect")
     station_logo = models.ForeignKey(Image, blank=True, null=True, on_delete=models.CASCADE)
     station_name = models.CharField(max_length=256, unique=True)
     station_website = models.URLField()
-- 
GitLab