--- /dev/null
+from datetime import timedelta
+from django.core.management.base import BaseCommand, CommandError
+from django.utils.timezone import now
+from club.models import Schedule
+
+
+class Command(BaseCommand):
+ def handle(self, *args, **options):
+ for s in Schedule.objects.filter(is_cancelled=False, expires_at__lt=now() + timedelta(1)):
+ print(s, s.email, s.expires_at)
+ s.pay(None)
+
def pay(self, request, schedule):
# Create order, put it and see what happens next.
from .models import PayUOrder
+ if request is not None:
+ ip = request.META['REMOTE_ADDR']
+ else:
+ ip = '127.0.0.1'
order = PayUOrder.objects.create(
pos_id=self.pos_id,
- customer_ip=request.META['REMOTE_ADDR'],
+ customer_ip=ip,
schedule=schedule,
)
return order.put()