Skip to content
Snippets Groups Projects
Verified Commit c41322a6 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: add feedback pools field and validation

parent d0ba9abc
No related branches found
No related tags found
No related merge requests found
# Generated by Django 4.2.13 on 2024-06-25 19:31
import program.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("program", "0101_alter_radiosettings_host_image_aspect_ratio_and_more"),
]
operations = [
migrations.AddField(
model_name="radiosettings",
name="fallback_pools",
field=models.JSONField(
blank=True,
default=dict,
help_text="JSON key/value pairs",
validators=[program.models.validate_fallback_pools],
),
),
]
......@@ -603,6 +603,20 @@ def validate_line_in_channels(value):
raise DjangoValidationError(e.args[0])
def validate_fallback_pools(value):
schema = {
"type": "object",
"patternProperties": {
"^.*$": {"type": "string"},
},
}
try:
jsonschema.validate(value, schema)
except jsonschema.exceptions.ValidationError as e:
raise DjangoValidationError(e.args[0])
class RadioSettings(models.Model):
cba_api_key = models.CharField(blank=True, max_length=64, verbose_name="CBA API key")
cba_domains = models.JSONField(
......@@ -613,6 +627,12 @@ class RadioSettings(models.Model):
verbose_name="CBA domains",
)
fallback_default_pool = models.CharField(blank=True, max_length=32)
fallback_pools = models.JSONField(
blank=True,
default=dict,
help_text="JSON key/value pairs",
validators=[validate_fallback_pools],
)
fallback_show = models.ForeignKey(
Show, blank=True, null=True, on_delete=models.CASCADE, related_name="+"
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment