X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6592ad610dc42a6242b5d5446addfb7a1feb01e0..d527b63f5320d32e5c598354fd60ebc00d88d7bb:/src/club/migrations/0013_populate_payed_at.py diff --git a/src/club/migrations/0013_populate_payed_at.py b/src/club/migrations/0013_populate_payed_at.py new file mode 100644 index 000000000..68b335ec9 --- /dev/null +++ b/src/club/migrations/0013_populate_payed_at.py @@ -0,0 +1,26 @@ +# Generated by Django 2.2.5 on 2019-09-30 13:13 +import json +from django.db import migrations + + +def populate_payed_at(apps, schema_editor): + PayUNotification = apps.get_model('club', 'PayUNotification') + for notification in PayUNotification.objects.order_by('received_at'): + status = json.loads(notification.body)['order']['status'] + schedule = notification.order.schedule + if status == 'COMPLETED' and schedule.payed_at is None: + schedule.payed_at = notification.received_at + schedule.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('club', '0012_auto_20190930_1510'), + ] + + operations = [ + migrations.RunPython( + populate_payed_at, + migrations.RunPython.noop, + elidable=True) + ]