Skip to content
Permalink
1577a6fca6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
19 lines (17 sloc) 583 Bytes
from .models import OrderItem
from datetime import timedelta,datetime
def expired_order_items():
#get time now
time_now = datetime.now()
#querry order items with expired set to false
qs = OrderItem.objects.filter(expired=False)
#for items in qs:
for item in qs:
#set expiry date = orderitem .date created + timedelta(minutes=2)
expiry_date = item.date_created + timedelta(minutes=2)
#check if time now < expiry date:
if time_now >= expiry_date:
#set expired field to true
item.expired = True
# delete order item
item.delete()