aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-09-25 18:10:38 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-09-26 16:36:47 +0200
commit5b5f16fe87e1902e863800cc9741233548091d98 (patch)
treeb22bfe12616e494acc69b44e94ac59f41e90802c
parentMerge pull request #251 from python-discord/update-linting (diff)
Migrate hidden warnings to notes
https://github.com/python-discord/site/issues/260 We have added a new "note" type to the Infraction model, meaning that we can now decouple notes and warnings completely. However, notes made prior to this change are still registered as "hidden warnings". This commit adds a data migration that sets the type field of "hidden warning" infractions to "note". This commit implements the first part of #260
-rw-r--r--pydis_site/apps/api/migrations/0043_infraction_hidden_warnings_to_notes.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0043_infraction_hidden_warnings_to_notes.py b/pydis_site/apps/api/migrations/0043_infraction_hidden_warnings_to_notes.py
new file mode 100644
index 00000000..7c751f5d
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0043_infraction_hidden_warnings_to_notes.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.5 on 2019-09-25 08:41
+
+from django.db import migrations
+
+
+def migrate_hidden_warnings_to_notes(apps, schema_editor):
+ """Migrates hidden warnings to note."""
+ Infraction = apps.get_model('api', 'Infraction')
+
+ for infraction in Infraction.objects.filter(type="warning", hidden=True):
+ infraction.type = "note"
+ infraction.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0042_infraction_add_default_ordering'),
+ ]
+
+ operations = [
+ migrations.RunPython(migrate_hidden_warnings_to_notes),
+ ]