From c5595ab82374febb9f77cc9db29acc17ecffcc4f Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Mon, 14 Oct 2024 23:29:16 +0100 Subject: [PATCH] subscription channels required set blank=False, meaning 400 error will be raised if the channels field is missing or blank. --- .../0013_alter_subscription_channels.py | 18 ++++++++++++++++++ apps/home/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 apps/home/migrations/0013_alter_subscription_channels.py diff --git a/apps/home/migrations/0013_alter_subscription_channels.py b/apps/home/migrations/0013_alter_subscription_channels.py new file mode 100644 index 0000000..4e826b1 --- /dev/null +++ b/apps/home/migrations/0013_alter_subscription_channels.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.4 on 2024-10-14 22:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0012_alter_server_is_bot_operational'), + ] + + operations = [ + migrations.AlterField( + model_name='subscription', + name='channels', + field=models.ManyToManyField(related_name='subscriptions', to='home.discordchannel'), + ), + ] diff --git a/apps/home/models.py b/apps/home/models.py index 5fb87ce..0883022 100644 --- a/apps/home/models.py +++ b/apps/home/models.py @@ -238,7 +238,7 @@ class Subscription(models.Model): active = models.BooleanField(default=True) publish_threshold = models.DateTimeField(default=timezone.now) - channels = models.ManyToManyField(to=DiscordChannel, related_name="subscriptions", blank=True) + channels = models.ManyToManyField(to=DiscordChannel, related_name="subscriptions", blank=False) filters = models.ManyToManyField(to=ContentFilter, blank=True) message_style = models.ForeignKey(to=MessageStyle, on_delete=models.SET_NULL, null=True, blank=True) unique_rules = models.ManyToManyField(to=UniqueContentRule, blank=False)