You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
762 B
Python
21 lines
762 B
Python
from logging import getLogger
|
|
from huey import crontab
|
|
from huey.contrib.djhuey import periodic_task
|
|
from sales.models import ItemSale
|
|
|
|
|
|
logger = getLogger('django.server')
|
|
|
|
@periodic_task(crontab(minute='0', hour='*/12'))
|
|
def close_completed_item_sales():
|
|
item_sales = ItemSale.objects.filter(platform_paid=True, sale_finalized=True)
|
|
for sale in item_sales:
|
|
logger.info(f'[INFO] Deleting item #{sale.item.id} and all accompanying bids, sales, meta, etc.')
|
|
sale.item.delete()
|
|
|
|
@periodic_task(crontab(minute='*'))
|
|
def close_cancelled_item_sales():
|
|
item_sales = ItemSale.objects.filter(sale_cancelled=True, payment_refunded=True)
|
|
for sale in item_sales:
|
|
logger.info(f'[INFO] Deleting sale #{sale.id}.')
|
|
sale.delete() |