23 lines
781 B
Python
23 lines
781 B
Python
import logging
|
|
from datetime import timedelta
|
|
|
|
from django.utils import timezone
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from combo.apps.lingo.models import Transaction, EXPIRED
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
def handle(self, *args, **kwargs):
|
|
logger = logging.getLogger(__name__)
|
|
now = timezone.now()
|
|
for transaction in Transaction.objects.filter(start_date__lt=now-timedelta(hours=1),
|
|
end_date__isnull=True):
|
|
logger.info('transaction %r is expired', transaction.order_id)
|
|
transaction.status = EXPIRED
|
|
transaction.save()
|
|
|
|
for transaction in Transaction.objects.filter(to_be_paid_remote_items__isnull=False):
|
|
transaction.retry_notify_remote_items_of_payments()
|