paypal
[wolnelektury.git] / src / club / migrations / 0030_populate_method.py
diff --git a/src/club/migrations/0030_populate_method.py b/src/club/migrations/0030_populate_method.py
new file mode 100644 (file)
index 0000000..40b2cdd
--- /dev/null
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.19 on 2021-06-18 10:11
+
+from django.db import migrations, models
+
+
+def populate_method(apps, schema_editor):
+    Schedule = apps.get_model('club', 'Schedule')
+    Schedule.objects.filter(method='', monthly=False, yearly=False).update(method='payu')
+    Schedule.objects.filter(
+        models.Q(monthly=True) | models.Q(yearly=True),
+        method=''
+    ).update(method='payu-re')
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('club', '0029_schedule_method'),
+    ]
+
+    operations = [
+        migrations.RunPython(populate_method, migrations.RunPython.noop)
+    ]