From 962803f86e8aebd057e4542a3fa7574d0a9b71a9 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Thu, 11 Apr 2024 16:31:25 -0400
Subject: [PATCH] feat: add RadioSettings model

---
 program/migrations/0088_radiosettings.py | 65 ++++++++++++++++++++++++
 program/models.py                        | 18 +++++++
 2 files changed, 83 insertions(+)
 create mode 100644 program/migrations/0088_radiosettings.py

diff --git a/program/migrations/0088_radiosettings.py b/program/migrations/0088_radiosettings.py
new file mode 100644
index 00000000..e52f9b0c
--- /dev/null
+++ b/program/migrations/0088_radiosettings.py
@@ -0,0 +1,65 @@
+# Generated by Django 4.2.11 on 2024-04-11 15:14
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("program", "0087_playlist"),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name="RadioSettings",
+            fields=[
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
+                    ),
+                ),
+                (
+                    "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",
+                    ),
+                ),
+                (
+                    "playout_channels",
+                    models.JSONField(blank=True, default=dict, help_text="JSON key/value pairs"),
+                ),
+                ("station_name", models.CharField(max_length=256, unique=True)),
+                ("station_website", models.URLField()),
+                (
+                    "fallback_show",
+                    models.ForeignKey(
+                        blank=True,
+                        null=True,
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to="program.show",
+                    ),
+                ),
+                (
+                    "station_logo",
+                    models.ForeignKey(
+                        blank=True,
+                        null=True,
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to="program.image",
+                    ),
+                ),
+            ],
+            options={
+                "verbose_name_plural": "Radio Settings",
+            },
+        ),
+    ]
diff --git a/program/models.py b/program/models.py
index 5217837d..70f659e1 100644
--- a/program/models.py
+++ b/program/models.py
@@ -525,3 +525,21 @@ class Playlist(models.Model):
             ("add__line", "Can add line media-source"),
             ("add__stream", "Can add stream media-source"),
         ]
+
+
+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)
+    playout_channels = models.JSONField(blank=True, default=dict, help_text="JSON key/value pairs")
+    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()
+
+    class Meta:
+        verbose_name_plural = "Radio Settings"
+
+    def __str__(self):
+        return self.station_name
-- 
GitLab