From 1577a6fca69226fd594edbae75cecbe682bc7746 Mon Sep 17 00:00:00 2001 From: Nour Elgeziry Date: Fri, 16 Oct 2020 15:02:33 +0100 Subject: [PATCH 1/6] Adding refresh basket functionality --- EDMS/EDMS/settings.py | 5 ++ EDMS/db.sqlite3 | Bin 176128 -> 176128 bytes EDMS/shoppingCart/admin.py | 2 +- EDMS/shoppingCart/cron.py | 19 +++++ .../migrations/0004_auto_20201016_1152.py | 25 +++++++ EDMS/shoppingCart/models.py | 8 +++ EDMS/shoppingCart/urls.py | 1 + EDMS/shoppingCart/views.py | 10 ++- Pipfile | 1 + Pipfile.lock | 68 ++++++++++-------- 10 files changed, 106 insertions(+), 33 deletions(-) create mode 100644 EDMS/shoppingCart/cron.py create mode 100644 EDMS/shoppingCart/migrations/0004_auto_20201016_1152.py diff --git a/EDMS/EDMS/settings.py b/EDMS/EDMS/settings.py index f52dfaa..aa7c150 100644 --- a/EDMS/EDMS/settings.py +++ b/EDMS/EDMS/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'shoppingCart', + 'django_crontab', ] @@ -82,6 +83,10 @@ DATABASES = { } } +#cron job +CRONJOBS = [ + ('*/1 * * * *', 'shoppingCart.cron.expired_order_items') +] # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators diff --git a/EDMS/db.sqlite3 b/EDMS/db.sqlite3 index 7a7ebb5e5a134d0e3c63bfae6717fb35fed32679..3949114ba35618b3ca01cef955a432897fdacb18 100644 GIT binary patch delta 1194 zcmaJ=O>7%Q6yCS9>-B6BkKIN#Nn2REY2rA+-d(R_uOm^pZV+v(CMw~8NaeWk3hWr$ zbsd4Is#vvp;KWamMg>|TQMGVDq_PxWDm98YAr43!5VVJIDF_KsIDk~;!0Z;$mQq&x zzIikAzVGe4dE45STif#6dwg3Q$Bi*Nz>H_M@XmM~wyrH)Cde<(u1el9UY_k_ynE%t zhx{UUU@~+1m0G=Cs=k~pG@7ca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art/admin.py b/EDMS/shoppingCart/admin.py index 4a85f36..765f09f 100644 --- a/EDMS/shoppingCart/admin.py +++ b/EDMS/shoppingCart/admin.py @@ -5,4 +5,4 @@ from .models import * admin.site.register(Customer) admin.site.register(Product) admin.site.register(Order) -admin.site.register(OrderItem) \ No newline at end of file +admin.site.register(OrderItem) diff --git a/EDMS/shoppingCart/cron.py b/EDMS/shoppingCart/cron.py new file mode 100644 index 0000000..d16f132 --- /dev/null +++ b/EDMS/shoppingCart/cron.py @@ -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() \ No newline at end of file diff --git a/EDMS/shoppingCart/migrations/0004_auto_20201016_1152.py b/EDMS/shoppingCart/migrations/0004_auto_20201016_1152.py new file mode 100644 index 0000000..7dd980f --- /dev/null +++ b/EDMS/shoppingCart/migrations/0004_auto_20201016_1152.py @@ -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), + ), + ] diff --git a/EDMS/shoppingCart/models.py b/EDMS/shoppingCart/models.py index 708d2a8..42573f7 100644 --- a/EDMS/shoppingCart/models.py +++ b/EDMS/shoppingCart/models.py @@ -1,6 +1,7 @@ from django.db import models from django.contrib.auth.models import User + # Create your models here. class Customer(models.Model): @@ -22,6 +23,7 @@ class Product(models.Model): class Order(models.Model): customer = models.ForeignKey(Customer, on_delete = models.SET_NULL, blank=True, null=True) complete = models.BooleanField(default=False, null=True, blank=True) + def __str__ (self): return str(self.id) @@ -30,7 +32,13 @@ class OrderItem(models.Model): product = models.ForeignKey(Product, on_delete=models.SET_NULL, blank=True, null=True) order = models.ForeignKey(Order, on_delete=models.SET_NULL, blank=True, null=True) quantity = models.IntegerField(default=0, null=True, blank=True) + date_created = models.DateTimeField(auto_now_add=True) + expired = models.BooleanField(default=False) def __str__(self): return self.product.name + + + + \ No newline at end of file diff --git a/EDMS/shoppingCart/urls.py b/EDMS/shoppingCart/urls.py index f769612..1eb81d2 100644 --- a/EDMS/shoppingCart/urls.py +++ b/EDMS/shoppingCart/urls.py @@ -7,3 +7,4 @@ urlpatterns = [ path('updateItem/', views.updateItem, name="updateItem"), ] + diff --git a/EDMS/shoppingCart/views.py b/EDMS/shoppingCart/views.py index db35600..fb641b8 100644 --- a/EDMS/shoppingCart/views.py +++ b/EDMS/shoppingCart/views.py @@ -29,13 +29,17 @@ def updateItem(request): order, created = Order.objects.get_or_create(customer=customer,complete=False) orderItem, created = OrderItem.objects.get_or_create(order=order, product=product) + #query order that did not expire + #querry orderitems in the order + #make sure the quantity does not exceed 9 + if orderItem.quantity >= 9 : messages.error(request, 'You bought 9 ' + str(orderItem.product) +"'s this week already") exit elif action == 'add': orderItem.quantity = (orderItem.quantity + 1) elif action =='remove': - orderItem.quantity = (orderItem.quantity -1) + orderItem.quantity = (orderItem.quantity - 1) orderItem.save() @@ -43,4 +47,6 @@ def updateItem(request): orderItem.delete() print('ProductID: ', productId, 'Action:',action) - return JsonResponse('item added', safe=False) \ No newline at end of file + return JsonResponse('item added', safe=False) + + diff --git a/Pipfile b/Pipfile index 66f5798..7a8362b 100644 --- a/Pipfile +++ b/Pipfile @@ -8,6 +8,7 @@ verify_ssl = true [packages] django = "*" pillow = "*" +django-crontab = "*" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 33c79b7..0301188 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "27d0ce8ecd9e1d08f1468feb6747fd86011dc9b6f199b0b9d97c65a0779d174e" + "sha256": "292744283c56cc32f20b13692b19ffe1958359200bfe6539399352866167da4e" }, "pipfile-spec": 6, "requires": { @@ -32,39 +32,47 @@ "index": "pypi", "version": "==3.1.2" }, + "django-crontab": { + "hashes": [ + "sha256:1201810a212460aaaa48eb6a766738740daf42c1a4f6aafecfb1525036929236" + ], + "index": "pypi", + "version": "==0.7.1" + }, "pillow": { "hashes": [ - "sha256:0295442429645fa16d05bd567ef5cff178482439c9aad0411d3f0ce9b88b3a6f", - "sha256:06aba4169e78c439d528fdeb34762c3b61a70813527a2c57f0540541e9f433a8", - "sha256:09d7f9e64289cb40c2c8d7ad674b2ed6105f55dc3b09aa8e4918e20a0311e7ad", - "sha256:0a80dd307a5d8440b0a08bd7b81617e04d870e40a3e46a32d9c246e54705e86f", - "sha256:1ca594126d3c4def54babee699c055a913efb01e106c309fa6b04405d474d5ae", - "sha256:25930fadde8019f374400f7986e8404c8b781ce519da27792cbe46eabec00c4d", - "sha256:431b15cffbf949e89df2f7b48528be18b78bfa5177cb3036284a5508159492b5", - "sha256:52125833b070791fcb5710fabc640fc1df07d087fc0c0f02d3661f76c23c5b8b", - "sha256:5e51ee2b8114def244384eda1c82b10e307ad9778dac5c83fb0943775a653cd8", - "sha256:612cfda94e9c8346f239bf1a4b082fdd5c8143cf82d685ba2dba76e7adeeb233", - "sha256:6d7741e65835716ceea0fd13a7d0192961212fd59e741a46bbed7a473c634ed6", - "sha256:6edb5446f44d901e8683ffb25ebdfc26988ee813da3bf91e12252b57ac163727", - "sha256:725aa6cfc66ce2857d585f06e9519a1cc0ef6d13f186ff3447ab6dff0a09bc7f", - "sha256:8dad18b69f710bf3a001d2bf3afab7c432785d94fcf819c16b5207b1cfd17d38", - "sha256:94cf49723928eb6070a892cb39d6c156f7b5a2db4e8971cb958f7b6b104fb4c4", - "sha256:97f9e7953a77d5a70f49b9a48da7776dc51e9b738151b22dacf101641594a626", - "sha256:9ad7f865eebde135d526bb3163d0b23ffff365cf87e767c649550964ad72785d", - "sha256:9c87ef410a58dd54b92424ffd7e28fd2ec65d2f7fc02b76f5e9b2067e355ebf6", - "sha256:a060cf8aa332052df2158e5a119303965be92c3da6f2d93b6878f0ebca80b2f6", - "sha256:c79f9c5fb846285f943aafeafda3358992d64f0ef58566e23484132ecd8d7d63", - "sha256:c92302a33138409e8f1ad16731568c55c9053eee71bb05b6b744067e1b62380f", - "sha256:d08b23fdb388c0715990cbc06866db554e1822c4bdcf6d4166cf30ac82df8c41", - "sha256:d350f0f2c2421e65fbc62690f26b59b0bcda1b614beb318c81e38647e0f673a1", - "sha256:e901964262a56d9ea3c2693df68bc9860b8bdda2b04768821e4c44ae797de117", - "sha256:ec29604081f10f16a7aea809ad42e27764188fc258b02259a03a8ff7ded3808d", - "sha256:edf31f1150778abd4322444c393ab9c7bd2af271dd4dafb4208fb613b1f3cdc9", - "sha256:f7e30c27477dffc3e85c2463b3e649f751789e0f6c8456099eea7ddd53be4a8a", - "sha256:ffe538682dc19cc542ae7c3e504fdf54ca7f86fb8a135e59dd6bc8627eae6cce" + "sha256:04d984e45a0b9815f4b407e8aadb50f25fbb82a605d89db927376e94c3adf371", + "sha256:06e730451b70471c08b8a0ee7f18e7e1df310dba9c780bbfb730a13102b143db", + "sha256:1f59596af2b3d64a9e43f9d6509b7a51db744d0eecc23297617c604e6823c6ae", + "sha256:233513465a2f25fce537b965621866da3d1f02e15708f371dd4e19f0fb7b7711", + "sha256:2696f1a6402c1a42ed12c5cd8adfb4b381c32d41e35a34b8ee544309ef854172", + "sha256:2ca55a4443b463eec90528ac27be14d226b1c2b972178bc7d4d282ce89e47b6a", + "sha256:30615e9115f976e00a938a28c7152562e8cf8e221ddacf4446dd8b20c0d97333", + "sha256:3a77e7b9f8991b81d7be8e0b2deab05013cf3ebb24ac2b863d2979acb68c73dd", + "sha256:54667c8ab16658cc0b7d824d8706b440d4db8382a3561042758bdfd48ca99298", + "sha256:59304c67d12394815331eda95ec892bf54ad95e0aa7bc1ccd8e0a4a5a25d4bf3", + "sha256:594f2f25b7bcfd9542c41b9df156fb5104f19f5fcefa51b1447f1d9f64c9cc14", + "sha256:5b5dde5dcedc4e6f5a71d7654a3c6e189ced82e97d7896b1ca5a5c5e4e0e916f", + "sha256:6bcea85f93fb2c94a1bcd35704c348a929a7fb24a0ec0cc2b9fcbb0046b87176", + "sha256:718d7f0eb3351052023b33fe0f83fc9e3beeb7cbacbd0ff2b52524e2153e4598", + "sha256:7c4a7ee37027ca716f42726b6f9fc491c13c843c7af559e0767dfab1ae9682d4", + "sha256:87a855b64a9b692604f6339baa4f9913d06838df1b4ccf0cb899dd18f56ec03c", + "sha256:8c006d52365c0a6bb41a07f9c8f9f458ae8170e0af3b8c49bf7089347066b97b", + "sha256:8e29701229705615d3dcfc439c7c46f40f913e57c7fe322b1efc30d3f37d1287", + "sha256:9b5b41737853bc49943864d5980dfb401a09e78ddb471e71291810ccdeadd712", + "sha256:b04569ff215b85ce3e2954979d2d5e0bf84007e43ddcf84b632fc6bc18e07909", + "sha256:b731d45764349313bd956c07bdc1d43803bb0ad2b11354328a074e416c7d84bc", + "sha256:c12e33cb17e2e12049a49b77696ee479791a4e44e541fdc393ae043e1246389f", + "sha256:c41442c3814afeba1f6f16fd70cdf312a2c73c6dee8dc3ac8926bb115713ad1d", + "sha256:c4d743c5c91424965707c9c8edc58b7cb43c127dcaf191fbcd304e2082eef56a", + "sha256:d6766fd28f4f47cf93280a57e3dc6a9d11bdada1a6e9f019b8c62b12bbc86f6a", + "sha256:d904570afcdbec40eb6bdbe24cba8d95c0215a2c0cbbc9c16301045bc8504c1f", + "sha256:e674be2f349ea810e221b0113bd4491f53584ac848d5bcc3b62443cfa11d9c40", + "sha256:e6ac40f1a62a227eb00226eb64c9c82bc878a3ed700b5414d34c9be57be87e87", + "sha256:f5270369c799b4405ed47d45c88c09fbd7942fc9fb9891c0dabf0b8c751b625d" ], "index": "pypi", - "version": "==7.2.0" + "version": "==8.0.0" }, "pytz": { "hashes": [ From 9edcadbd0c8a74e177849e357ef93fc309d63f95 Mon Sep 17 00:00:00 2001 From: Nour Elgeziry Date: Sun, 18 Oct 2020 22:15:08 +0100 Subject: [PATCH 2/6] basket refreshes automaticaly every 2 minutes --- .DS_Store | Bin 6148 -> 6148 bytes EDMS/EDMS/__init__.py | 5 ++ EDMS/EDMS/celery.py | 21 +++++ EDMS/EDMS/settings.py | 13 +-- EDMS/db.sqlite3 | Bin 176128 -> 188416 bytes EDMS/shoppingCart/admin.py | 1 + EDMS/shoppingCart/cron.py | 19 ---- EDMS/shoppingCart/migrations/0005_test.py | 20 +++++ .../migrations/0006_auto_20201018_1229.py | 26 ++++++ .../migrations/0007_auto_20201018_1316.py | 28 ++++++ .../migrations/0008_auto_20201018_1342.py | 29 ++++++ .../migrations/0009_auto_20201018_1354.py | 23 +++++ .../migrations/0010_auto_20201018_1401.py | 22 +++++ .../migrations/0011_order_complete.py | 18 ++++ .../migrations/0012_auto_20201018_1430.py | 19 ++++ .../migrations/0013_auto_20201018_1439.py | 19 ++++ .../migrations/0014_auto_20201018_1443.py | 21 +++++ .../migrations/0015_auto_20201018_1448.py | 27 ++++++ .../migrations/0016_auto_20201018_1456.py | 27 ++++++ .../migrations/0017_order_orderitem.py | 38 ++++++++ .../migrations/0018_auto_20201018_1522.py | 24 +++++ .../migrations/0019_auto_20201018_1759.py | 31 +++++++ .../migrations/0020_auto_20201018_2051.py | 20 +++++ .../migrations/0021_auto_20201018_2056.py | 19 ++++ EDMS/shoppingCart/models.py | 21 ++--- EDMS/shoppingCart/urls.py | 1 + EDMS/shoppingCart/views.py | 40 +++++++-- EDMS/static/js/cart.js | 2 +- Pipfile | 1 + Pipfile.lock | 85 +++++++++++++++++- 30 files changed, 575 insertions(+), 45 deletions(-) create mode 100644 EDMS/EDMS/celery.py delete mode 100644 EDMS/shoppingCart/cron.py create mode 100644 EDMS/shoppingCart/migrations/0005_test.py create mode 100644 EDMS/shoppingCart/migrations/0006_auto_20201018_1229.py create mode 100644 EDMS/shoppingCart/migrations/0007_auto_20201018_1316.py create mode 100644 EDMS/shoppingCart/migrations/0008_auto_20201018_1342.py create mode 100644 EDMS/shoppingCart/migrations/0009_auto_20201018_1354.py create mode 100644 EDMS/shoppingCart/migrations/0010_auto_20201018_1401.py create mode 100644 EDMS/shoppingCart/migrations/0011_order_complete.py create mode 100644 EDMS/shoppingCart/migrations/0012_auto_20201018_1430.py create mode 100644 EDMS/shoppingCart/migrations/0013_auto_20201018_1439.py create mode 100644 EDMS/shoppingCart/migrations/0014_auto_20201018_1443.py create mode 100644 EDMS/shoppingCart/migrations/0015_auto_20201018_1448.py create mode 100644 EDMS/shoppingCart/migrations/0016_auto_20201018_1456.py create mode 100644 EDMS/shoppingCart/migrations/0017_order_orderitem.py create mode 100644 EDMS/shoppingCart/migrations/0018_auto_20201018_1522.py create mode 100644 EDMS/shoppingCart/migrations/0019_auto_20201018_1759.py create mode 100644 EDMS/shoppingCart/migrations/0020_auto_20201018_2051.py create mode 100644 EDMS/shoppingCart/migrations/0021_auto_20201018_2056.py diff --git a/.DS_Store b/.DS_Store index c10ec4f00dff4f9523e59f9c56fe64d8efcafc46..dc5052e198cef2cbe9bb1ba3a30caee6d0d21248 100644 GIT binary patch literal 6148 zcmeHKF>ezw6n<_)a|u*LZKZa+1&JX-7YY;!Azec;&1OuQpmkY^>%Q?zj8kG>p z!Vf@Vpk-lY<2SJJ3z+#4h!NhiO%z`!V?~jlWPi5bd-n5ZpM3@ZRviQtfD!;$mE#xr!*%Es$~_CQ6Eve;x&1L z_pyx*gZlU5&)d2__^ZCxnK>JlKcOq+aoht)pa~oTXlbJZyqdSj#PH+ok%%GFPnTo;VUjw|SGKU2JGYd# ztfEz1ENrhzG(zTrb<3&dqVz9&K$oW&7IZjq$i(tzW9#-r4US zJ|DdpzdRCC0EP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0}H&Thm~u zid{NIL*V;MM0A4I+c#wTvc28gx_zFmOs1FZo}g(= expiry_date: - #set expired field to true - item.expired = True - # delete order item - item.delete() \ No newline at end of file diff --git a/EDMS/shoppingCart/migrations/0005_test.py b/EDMS/shoppingCart/migrations/0005_test.py new file mode 100644 index 0000000..645b4d2 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0005_test.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.2 on 2020-10-16 14:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0004_auto_20201016_1152'), + ] + + operations = [ + migrations.CreateModel( + name='Test', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=4)), + ], + ), + ] diff --git a/EDMS/shoppingCart/migrations/0006_auto_20201018_1229.py b/EDMS/shoppingCart/migrations/0006_auto_20201018_1229.py new file mode 100644 index 0000000..7277723 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0006_auto_20201018_1229.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.2 on 2020-10-18 12:29 + +import datetime +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0005_test'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='date_created', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + migrations.AddField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 12, 30, 18, 872950)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0007_auto_20201018_1316.py b/EDMS/shoppingCart/migrations/0007_auto_20201018_1316.py new file mode 100644 index 0000000..ba38b4a --- /dev/null +++ b/EDMS/shoppingCart/migrations/0007_auto_20201018_1316.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.2 on 2020-10-18 13:16 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0006_auto_20201018_1229'), + ] + + operations = [ + migrations.RemoveField( + model_name='orderitem', + name='expired', + ), + migrations.AddField( + model_name='order', + name='expired', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 13, 17, 6, 8469)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0008_auto_20201018_1342.py b/EDMS/shoppingCart/migrations/0008_auto_20201018_1342.py new file mode 100644 index 0000000..2862aec --- /dev/null +++ b/EDMS/shoppingCart/migrations/0008_auto_20201018_1342.py @@ -0,0 +1,29 @@ +# Generated by Django 3.1.2 on 2020-10-18 13:42 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0007_auto_20201018_1316'), + ] + + operations = [ + migrations.AddField( + model_name='orderitem', + name='expired', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='order', + name='date_created', + field=models.DateTimeField(verbose_name=datetime.datetime(2020, 10, 18, 13, 42, 9, 885618)), + ), + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 13, 43, 9, 885636)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0009_auto_20201018_1354.py b/EDMS/shoppingCart/migrations/0009_auto_20201018_1354.py new file mode 100644 index 0000000..0e60faf --- /dev/null +++ b/EDMS/shoppingCart/migrations/0009_auto_20201018_1354.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.2 on 2020-10-18 13:54 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0008_auto_20201018_1342'), + ] + + operations = [ + migrations.RemoveField( + model_name='order', + name='date_created', + ), + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 13, 55, 33, 184566)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0010_auto_20201018_1401.py b/EDMS/shoppingCart/migrations/0010_auto_20201018_1401.py new file mode 100644 index 0000000..5d6f795 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0010_auto_20201018_1401.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0009_auto_20201018_1354'), + ] + + operations = [ + migrations.RemoveField( + model_name='order', + name='complete', + ), + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateField(), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0011_order_complete.py b/EDMS/shoppingCart/migrations/0011_order_complete.py new file mode 100644 index 0000000..c67ab7f --- /dev/null +++ b/EDMS/shoppingCart/migrations/0011_order_complete.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0010_auto_20201018_1401'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='complete', + field=models.BooleanField(default=False), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0012_auto_20201018_1430.py b/EDMS/shoppingCart/migrations/0012_auto_20201018_1430.py new file mode 100644 index 0000000..ae676dd --- /dev/null +++ b/EDMS/shoppingCart/migrations/0012_auto_20201018_1430.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:30 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0011_order_complete'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(verbose_name=datetime.date(2020, 10, 25)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0013_auto_20201018_1439.py b/EDMS/shoppingCart/migrations/0013_auto_20201018_1439.py new file mode 100644 index 0000000..e712115 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0013_auto_20201018_1439.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:39 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0012_auto_20201018_1430'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(null=True, verbose_name=datetime.date(2020, 10, 25)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0014_auto_20201018_1443.py b/EDMS/shoppingCart/migrations/0014_auto_20201018_1443.py new file mode 100644 index 0000000..f4aaeb4 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0014_auto_20201018_1443.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:43 + +import datetime +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0013_auto_20201018_1439'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(default=django.utils.timezone.now, verbose_name=datetime.date(2020, 10, 25)), + preserve_default=False, + ), + ] diff --git a/EDMS/shoppingCart/migrations/0015_auto_20201018_1448.py b/EDMS/shoppingCart/migrations/0015_auto_20201018_1448.py new file mode 100644 index 0000000..78ebe02 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0015_auto_20201018_1448.py @@ -0,0 +1,27 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:48 + +import datetime +from django.db import migrations, models +import django.utils.timezone +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0014_auto_20201018_1443'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='date_created', + field=models.DateTimeField(default=django.utils.timezone.now, verbose_name=datetime.datetime(2020, 10, 18, 14, 47, 51, 354484, tzinfo=utc)), + preserve_default=False, + ), + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(verbose_name=datetime.datetime(2020, 10, 25, 14, 47, 51, 354511, tzinfo=utc)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0016_auto_20201018_1456.py b/EDMS/shoppingCart/migrations/0016_auto_20201018_1456.py new file mode 100644 index 0000000..04fe58a --- /dev/null +++ b/EDMS/shoppingCart/migrations/0016_auto_20201018_1456.py @@ -0,0 +1,27 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:56 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0015_auto_20201018_1448'), + ] + + operations = [ + migrations.RemoveField( + model_name='orderitem', + name='order', + ), + migrations.RemoveField( + model_name='orderitem', + name='product', + ), + migrations.DeleteModel( + name='Order', + ), + migrations.DeleteModel( + name='OrderItem', + ), + ] diff --git a/EDMS/shoppingCart/migrations/0017_order_orderitem.py b/EDMS/shoppingCart/migrations/0017_order_orderitem.py new file mode 100644 index 0000000..66c1195 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0017_order_orderitem.py @@ -0,0 +1,38 @@ +# Generated by Django 3.1.2 on 2020-10-18 14:57 + +import datetime +from django.db import migrations, models +import django.db.models.deletion +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0016_auto_20201018_1456'), + ] + + operations = [ + migrations.CreateModel( + name='Order', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date_created', models.DateTimeField(verbose_name=datetime.datetime(2020, 10, 18, 14, 57, 32, 274339, tzinfo=utc))), + ('expiry_date', models.DateTimeField(verbose_name=datetime.datetime(2020, 10, 25, 14, 57, 32, 274372, tzinfo=utc))), + ('expired', models.BooleanField(default=False)), + ('complete', models.BooleanField(default=False)), + ('customer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='shoppingCart.customer')), + ], + ), + migrations.CreateModel( + name='OrderItem', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.IntegerField(blank=True, default=0, null=True)), + ('date_created', models.DateTimeField(auto_now_add=True)), + ('expired', models.BooleanField(default=False)), + ('order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='shoppingCart.order')), + ('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='shoppingCart.product')), + ], + ), + ] diff --git a/EDMS/shoppingCart/migrations/0018_auto_20201018_1522.py b/EDMS/shoppingCart/migrations/0018_auto_20201018_1522.py new file mode 100644 index 0000000..67f9b83 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0018_auto_20201018_1522.py @@ -0,0 +1,24 @@ +# Generated by Django 3.1.2 on 2020-10-18 15:22 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0017_order_orderitem'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='date_created', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 15, 22, 1, 700384)), + ), + migrations.AlterField( + model_name='order', + name='expiry_date', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 15, 24, 1, 700420)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0019_auto_20201018_1759.py b/EDMS/shoppingCart/migrations/0019_auto_20201018_1759.py new file mode 100644 index 0000000..95192db --- /dev/null +++ b/EDMS/shoppingCart/migrations/0019_auto_20201018_1759.py @@ -0,0 +1,31 @@ +# Generated by Django 3.1.2 on 2020-10-18 17:59 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0018_auto_20201018_1522'), + ] + + operations = [ + migrations.RemoveField( + model_name='order', + name='expiry_date', + ), + migrations.RemoveField( + model_name='orderitem', + name='date_created', + ), + migrations.RemoveField( + model_name='orderitem', + name='expired', + ), + migrations.AlterField( + model_name='order', + name='date_created', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 17, 59, 41, 21325)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0020_auto_20201018_2051.py b/EDMS/shoppingCart/migrations/0020_auto_20201018_2051.py new file mode 100644 index 0000000..87043e8 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0020_auto_20201018_2051.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.2 on 2020-10-18 20:51 + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0019_auto_20201018_1759'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='date_created', + field=models.DateTimeField(default=datetime.datetime(2020, 10, 18, 20, 51, 23, 928323, tzinfo=utc)), + ), + ] diff --git a/EDMS/shoppingCart/migrations/0021_auto_20201018_2056.py b/EDMS/shoppingCart/migrations/0021_auto_20201018_2056.py new file mode 100644 index 0000000..84dc0f8 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0021_auto_20201018_2056.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.2 on 2020-10-18 20:56 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0020_auto_20201018_2051'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='date_created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/EDMS/shoppingCart/models.py b/EDMS/shoppingCart/models.py index 42573f7..94f4452 100644 --- a/EDMS/shoppingCart/models.py +++ b/EDMS/shoppingCart/models.py @@ -1,9 +1,15 @@ from django.db import models from django.contrib.auth.models import User +from datetime import datetime, timedelta +from django.utils import timezone + # Create your models here. +class Test(models.Model): + name = models.CharField(max_length=4) + class Customer(models.Model): user = models.OneToOneField(User, on_delete =models.CASCADE, null=True, blank=True) name = models.CharField(max_length=200, null=True) @@ -22,9 +28,10 @@ class Product(models.Model): class Order(models.Model): customer = models.ForeignKey(Customer, on_delete = models.SET_NULL, blank=True, null=True) - complete = models.BooleanField(default=False, null=True, blank=True) + date_created = models.DateTimeField(default = timezone.now) + expired = models.BooleanField(default=False) + complete = models.BooleanField(default=False) - def __str__ (self): return str(self.id) @@ -32,13 +39,7 @@ class OrderItem(models.Model): product = models.ForeignKey(Product, on_delete=models.SET_NULL, blank=True, null=True) order = models.ForeignKey(Order, on_delete=models.SET_NULL, blank=True, null=True) quantity = models.IntegerField(default=0, null=True, blank=True) - date_created = models.DateTimeField(auto_now_add=True) - expired = models.BooleanField(default=False) - + def __str__(self): return self.product.name - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/EDMS/shoppingCart/urls.py b/EDMS/shoppingCart/urls.py index 1eb81d2..337689d 100644 --- a/EDMS/shoppingCart/urls.py +++ b/EDMS/shoppingCart/urls.py @@ -5,6 +5,7 @@ from django.urls import path urlpatterns = [ path('', views.main, name="main"), path('updateItem/', views.updateItem, name="updateItem"), + ] diff --git a/EDMS/shoppingCart/views.py b/EDMS/shoppingCart/views.py index fb641b8..7357d78 100644 --- a/EDMS/shoppingCart/views.py +++ b/EDMS/shoppingCart/views.py @@ -1,19 +1,46 @@ from django.shortcuts import render +from django.views import View from .models import * # Create your views here. -from django.http.response import JsonResponse +from django.http.response import JsonResponse, HttpResponse import json -from django.contrib import messages +import pytz # main page def main(request): + customer = Customer.objects.get(id=1) + products = Product.objects.all() order, created = Order.objects.get_or_create(customer=customer, complete= False) - customerOrderItem = order.orderitem_set.all() - products = Product.objects.all() + customerOrderItem = order.orderitem_set.all() + + #start time for order expiry + utc = pytz.UTC + print('date_Created:' + str(order.date_created)) + + expiry_time = timedelta(minutes=2) + print('expiry time' + str(expiry_time)) + + expiry_date = order.date_created + expiry_time + print('expiry_date:' + str(expiry_date)) + + date_now = utc.localize(datetime.now()) + print('date now:' + str(date_now)) + #check if expiry date is reached + if date_now >= expiry_date: + order.expired= True + order.save() + + #check if order is expired + if order.expired == True: + order.delete() + for item in customerOrderItem: + item.delete() + Order.objects.create(customer=customer, complete= False) + context = {'customer':customer, 'order':order, 'customerOrderItem':customerOrderItem, 'products':products} return render(request,'shoppingCart/main.html', context) @@ -26,11 +53,9 @@ def updateItem(request): customer = request.user.customer product = Product.objects.get(id=productId) - order, created = Order.objects.get_or_create(customer=customer,complete=False) + order, created = Order.objects.get_or_create(customer=customer, complete= False) orderItem, created = OrderItem.objects.get_or_create(order=order, product=product) - #query order that did not expire - #querry orderitems in the order #make sure the quantity does not exceed 9 if orderItem.quantity >= 9 : @@ -49,4 +74,3 @@ def updateItem(request): print('ProductID: ', productId, 'Action:',action) return JsonResponse('item added', safe=False) - diff --git a/EDMS/static/js/cart.js b/EDMS/static/js/cart.js index ffdfa10..7f8d110 100644 --- a/EDMS/static/js/cart.js +++ b/EDMS/static/js/cart.js @@ -18,7 +18,7 @@ for (i = 0; i < updateButton.length; i++) { function updateUserOrder(productId, action) { - var url = '/updateItem/' + var url = '/main_class/' fetch(url, { method: 'POST', diff --git a/Pipfile b/Pipfile index 7a8362b..e3bc28f 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ verify_ssl = true django = "*" pillow = "*" django-crontab = "*" +celery = "*" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 0301188..a146a7d 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "292744283c56cc32f20b13692b19ffe1958359200bfe6539399352866167da4e" + "sha256": "d9d9a412445aee8a1e4ebb76250dda9d583b4ccd098608581d3a31152a3dfc3c" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,14 @@ ] }, "default": { + "amqp": { + "hashes": [ + "sha256:9881f8e6fe23e3db9faa6cfd8c05390213e1d1b95c0162bc50552cad75bffa5f", + "sha256:a8fb8151eb9d12204c9f1784c0da920476077609fa0a70f2468001e3a4258484" + ], + "markers": "python_version >= '3.6'", + "version": "==5.0.1" + }, "asgiref": { "hashes": [ "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a", @@ -24,6 +32,42 @@ "markers": "python_version >= '3.5'", "version": "==3.2.10" }, + "billiard": { + "hashes": [ + "sha256:bff575450859a6e0fbc2f9877d9b715b0bbc07c3565bb7ed2280526a0cdf5ede", + "sha256:d91725ce6425f33a97dfa72fb6bfef0e47d4652acd98a032bd1a7fbf06d5fa6a" + ], + "version": "==3.6.3.0" + }, + "celery": { + "hashes": [ + "sha256:313930fddde703d8e37029a304bf91429cd11aeef63c57de6daca9d958e1f255", + "sha256:72138dc3887f68dc58e1a2397e477256f80f1894c69fa4337f8ed70be460375b" + ], + "index": "pypi", + "version": "==5.0.0" + }, + "click": { + "hashes": [ + "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", + "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==7.1.2" + }, + "click-didyoumean": { + "hashes": [ + "sha256:112229485c9704ff51362fe34b2d4f0b12fc71cc20f6d2b3afabed4b8bfa6aeb" + ], + "version": "==0.0.3" + }, + "click-repl": { + "hashes": [ + "sha256:9c4c3d022789cae912aad8a3f5e1d7c2cdd016ee1225b5212ad3e8691563cda5", + "sha256:b9f29d52abc4d6059f8e276132a111ab8d94980afe6a5432b9d996544afa95d5" + ], + "version": "==0.1.6" + }, "django": { "hashes": [ "sha256:a2127ad0150ec6966655bedf15dbbff9697cc86d61653db2da1afa506c0b04cc", @@ -39,6 +83,14 @@ "index": "pypi", "version": "==0.7.1" }, + "kombu": { + "hashes": [ + "sha256:6dc509178ac4269b0e66ab4881f70a2035c33d3a622e20585f965986a5182006", + "sha256:f4965fba0a4718d47d470beeb5d6446e3357a62402b16c510b6a2f251e05ac3c" + ], + "markers": "python_version >= '3.6'", + "version": "==5.0.2" + }, "pillow": { "hashes": [ "sha256:04d984e45a0b9815f4b407e8aadb50f25fbb82a605d89db927376e94c3adf371", @@ -74,6 +126,14 @@ "index": "pypi", "version": "==8.0.0" }, + "prompt-toolkit": { + "hashes": [ + "sha256:25c95d2ac813909f813c93fde734b6e44406d1477a9faef7c915ff37d39c0a8c", + "sha256:7debb9a521e0b1ee7d2fe96ee4bd60ef03c6492784de0547337ca4433e46aa63" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==3.0.8" + }, "pytz": { "hashes": [ "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed", @@ -81,6 +141,14 @@ ], "version": "==2020.1" }, + "six": { + "hashes": [ + "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", + "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.15.0" + }, "sqlparse": { "hashes": [ "sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0", @@ -88,6 +156,21 @@ ], "markers": "python_version >= '3.5'", "version": "==0.4.1" + }, + "vine": { + "hashes": [ + "sha256:4c9dceab6f76ed92105027c49c823800dd33cacce13bdedc5b914e3514b7fb30", + "sha256:7d3b1624a953da82ef63462013bbd271d3eb75751489f9807598e8f340bd637e" + ], + "markers": "python_version >= '3.6'", + "version": "==5.0.0" + }, + "wcwidth": { + "hashes": [ + "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784", + "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83" + ], + "version": "==0.2.5" } }, "develop": {} From 70aad0d364934772a5e72af87f63a69f5586df10 Mon Sep 17 00:00:00 2001 From: Nour Elgeziry Date: Mon, 19 Oct 2020 18:20:11 +0100 Subject: [PATCH 3/6] implemented removing items from both baskets. --- EDMS/.vscode/settings.json | 3 +++ EDMS/EDMS/__init__.py | 2 -- EDMS/EDMS/celery.py | 21 ------------------ EDMS/db.sqlite3 | Bin 188416 -> 188416 bytes .../templates/shoppingCart/main.html | 16 +++++++------ EDMS/shoppingCart/views.py | 9 ++++---- EDMS/static/js/cart.js | 5 +++-- 7 files changed, 20 insertions(+), 36 deletions(-) create mode 100644 EDMS/.vscode/settings.json delete mode 100644 EDMS/EDMS/celery.py diff --git a/EDMS/.vscode/settings.json b/EDMS/.vscode/settings.json new file mode 100644 index 0000000..4c1277d --- /dev/null +++ b/EDMS/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/Users/nourelgeziry/.local/share/virtualenvs/Equal_Distribution_maintainance-M-bcKwQz/bin/python" +} \ No newline at end of file diff --git a/EDMS/EDMS/__init__.py b/EDMS/EDMS/__init__.py index 1e3599b..6944829 100644 --- a/EDMS/EDMS/__init__.py +++ b/EDMS/EDMS/__init__.py @@ -1,5 +1,3 @@ # This will make sure the app is always imported when -# Django starts so that shared_task will use this app. -from .celery import app as celery_app __all__ = ('celery_app',) \ No newline at end of file diff --git a/EDMS/EDMS/celery.py b/EDMS/EDMS/celery.py deleted file mode 100644 index b81af5d..0000000 --- a/EDMS/EDMS/celery.py +++ /dev/null @@ -1,21 +0,0 @@ -import os -from celery import Celery - -# set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'EDMS.settings') - -app = Celery('EDMS') - -# Using a string here means the worker doesn't have to serialize -# the configuration object to child processes. -# - namespace='CELERY' means all celery-related configuration keys -# should have a `CELERY_` prefix. -app.config_from_object('django.conf:settings', namespace='CELERY') - -# Load task modules from all registered Django app configs. -app.autodiscover_tasks() - - -@app.task(bind=True) -def debug_task(self): - print(f'Request: {self.request!r}') \ No newline at end of file diff --git a/EDMS/db.sqlite3 b/EDMS/db.sqlite3 index 9438e11ced35b11132853fb2e41d0619f848f330..03e8abb57adc6784249c4be8d338b6f5b70234e9 100644 GIT binary patch delta 1339 zcmaizPe>I(9LMLk`~J=D#AtY^lw7lanm+gc>^@3-*eRkz_DAcY`Mh-U7z90~PMwS( zFOvWN)Qczz7ovj^M39F-iU>l2it3OZ%Ah~g%xqwX>M_gb`(ya*{Dzs`fdzeFK_9Ay z)eAN4uzIumWEM&nA7%GK;bKKgHT0crYKfX!;90*~(wBzQV^FW?OHtz(RKW(agBWBZ zSxmNRCU6NsdN~cfskX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