a216ac5b79023e0a4cd3f9038a47ca12e41915ac
[wolnelektury.git] / src / club / management / commands / payu_fake_notify.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 import json
5 from django.core.management.base import BaseCommand
6 from club.models import PayUOrder
7
8
9 class Command(BaseCommand):
10     def add_arguments(self, parser):
11         parser.add_argument('--rejected', '-r', type=bool, default=False)
12         parser.add_argument('order_id', type=int)
13     
14     def handle(self, **options):
15         order = PayUOrder.objects.get(id=options['order_id'])
16         status = 'REJECTED' if options['rejected'] else 'COMPLETED'
17         notification = order.notification_set.create(
18             body=json.dumps({
19                 'order': {
20                     'status': status,
21                     'fake': True,
22                 }
23             })
24         )
25         notification.apply()