Permalink
Cannot retrieve contributors at this time
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?
Equal-Distribution-maintenance-system/EDMS/shoppingCart/cron.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19 lines (17 sloc)
583 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |