Add grammar to tags. Also: respect custom tag slugs on publishing.
[wolnelektury.git] / src / club / migrations / 0023_completed_at.py
1 import json
2 from django.db import migrations
3
4
5 def populate_completed_at(apps, schema_editor):
6     PayUOrder = apps.get_model('club', 'PayUOrder')
7     for order in PayUOrder.objects.filter(status='COMPLETED'):
8         for n in order.notification_set.order_by('received_at'):
9             if json.loads(n.body)['order']['status'] == 'COMPLETED':
10                 order.completed_at = n.received_at
11                 order.save()
12                 break
13
14
15 class Migration(migrations.Migration):
16
17     dependencies = [
18         ('club', '0022_payuorder_completed_at'),
19     ]
20
21     operations = [
22         migrations.RunPython(
23             populate_completed_at,
24             migrations.RunPython.noop,
25         )
26     ]