lingo: cron for updating transactions status (#9744)
This commit is contained in:
parent
c39f9d31e9
commit
a3ce154e71
|
@ -0,0 +1,19 @@
|
|||
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()
|
|
@ -41,6 +41,8 @@ from combo.data.models import CellBase
|
|||
from combo.data.library import register_cell_class
|
||||
from combo.utils import NothingInCacheException, sign_url
|
||||
|
||||
EXPIRED = 9999
|
||||
|
||||
|
||||
SERVICES = [
|
||||
(eopayment.DUMMY, _('Dummy (for tests)')),
|
||||
|
@ -241,6 +243,7 @@ class Transaction(models.Model):
|
|||
0: _('Running'),
|
||||
eopayment.PAID: _('Paid'),
|
||||
eopayment.CANCELLED: _('Cancelled'),
|
||||
EXPIRED: _('Expired')
|
||||
}.get(self.status) or _('Unknown')
|
||||
|
||||
@register_cell_class
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
su combo -s /bin/sh -c "/usr/bin/combo-manage tenant_command update_transactions --all-tenants"
|
Loading…
Reference in New Issue