Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Adding refresh basket functionality
- Loading branch information
Nour Elgeziry
authored and
Nour Elgeziry
committed
Oct 16, 2020
1 parent
7cfe6d5
commit 1577a6fca69226fd594edbae75cecbe682bc7746
Showing
10 changed files
with
106 additions
and
33 deletions.
There are no files selected for viewing
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
BIN
+0 Bytes
(100%)
EDMS/db.sqlite3
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 3.1.2 on 2020-10-16 11:52 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('shoppingCart', '0003_auto_20201012_1250'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='orderitem', | ||
name='date_created', | ||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='orderitem', | ||
name='expired', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -7,3 +7,4 @@ urlpatterns = [ | ||
path('updateItem/', views.updateItem, name="updateItem"), | ||
] | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,6 +8,7 @@ verify_ssl = true | ||
[packages] | ||
django = "*" | ||
pillow = "*" | ||
django-crontab = "*" | ||
|
||
[requires] | ||
python_version = "3.8" |
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.