def handle(self, *args, **options):
now = timezone.now()
expdate = now - parse_duration(options['exp_time'])
self.stdout.write("Now: " + now.isoformat())
self.stdout.write("Exp: " + expdate.isoformat())
expired = Payment.objects.filter(created__lte=expdate, status='new',
paid_amount=0)
for p in expired:
self.stdout.write("Payment #%d (%s): %s" % (p.id, p.user.username, p.created))
if not options['sim']:
p.status = 'cancelled'
p.save()
评论列表
文章目录