aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar Joseph Banks <[email protected]>2020-04-30 14:06:58 +0100
committerGravatar GitHub <[email protected]>2020-04-30 14:06:58 +0100
commit923cbeae0079b4a542fffda19bf3bce3daf15205 (patch)
tree4ab70ce29fb3a4d783d5e015771572fa7943ba1a /pydis_site
parentMerge pull request #350 from python-discord/fix-link (diff)
parentFixed migration nr 51 `down` function object getting (diff)
Merge pull request #352 from ks129/news-bot-setting
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/api/migrations/0051_create_news_setting.py25
-rw-r--r--pydis_site/apps/api/models/bot/bot_setting.py1
2 files changed, 26 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0051_create_news_setting.py b/pydis_site/apps/api/migrations/0051_create_news_setting.py
new file mode 100644
index 00000000..f18fdfb1
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0051_create_news_setting.py
@@ -0,0 +1,25 @@
+from django.db import migrations
+
+
+def up(apps, schema_editor):
+ BotSetting = apps.get_model('api', 'BotSetting')
+ setting = BotSetting(
+ name='news',
+ data={}
+ ).save()
+
+
+def down(apps, schema_editor):
+ BotSetting = apps.get_model('api', 'BotSetting')
+ BotSetting.objects.get(name='news').delete()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0050_remove_infractions_active_default_value'),
+ ]
+
+ operations = [
+ migrations.RunPython(up, down)
+ ]
diff --git a/pydis_site/apps/api/models/bot/bot_setting.py b/pydis_site/apps/api/models/bot/bot_setting.py
index b1c3e47c..8d48eac7 100644
--- a/pydis_site/apps/api/models/bot/bot_setting.py
+++ b/pydis_site/apps/api/models/bot/bot_setting.py
@@ -9,6 +9,7 @@ def validate_bot_setting_name(name: str) -> None:
"""Raises a ValidationError if the given name is not a known setting."""
known_settings = (
'defcon',
+ 'news',
)
if name not in known_settings: