diff --git a/EDMS/db.sqlite3 b/EDMS/db.sqlite3 index 8997b35..844fc11 100644 Binary files a/EDMS/db.sqlite3 and b/EDMS/db.sqlite3 differ diff --git a/EDMS/shoppingCart/migrations/0012_auto_20201020_1637.py b/EDMS/shoppingCart/migrations/0012_auto_20201020_1637.py new file mode 100644 index 0000000..fb4e59d --- /dev/null +++ b/EDMS/shoppingCart/migrations/0012_auto_20201020_1637.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.2 on 2020-10-20 15:37 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0011_auto_20201019_1709'), + ] + + operations = [ + migrations.RenameField( + model_name='storeorder', + old_name='date_created', + new_name='date', + ), + ] diff --git a/EDMS/shoppingCart/migrations/0013_auto_20201020_1706.py b/EDMS/shoppingCart/migrations/0013_auto_20201020_1706.py new file mode 100644 index 0000000..6f24363 --- /dev/null +++ b/EDMS/shoppingCart/migrations/0013_auto_20201020_1706.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.2 on 2020-10-20 16:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shoppingCart', '0012_auto_20201020_1637'), + ] + + operations = [ + migrations.AlterField( + model_name='storeorder', + name='date', + field=models.DateTimeField(), + ), + ] diff --git a/EDMS/shoppingCart/models.py b/EDMS/shoppingCart/models.py index cf661c8..2de2a2c 100644 --- a/EDMS/shoppingCart/models.py +++ b/EDMS/shoppingCart/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.auth.models import User +from datetime import timezone, datetime # Create your models here. @@ -52,7 +53,8 @@ class StoreOrder(models.Model): product = models.ForeignKey(Product, on_delete=models.SET_NULL, blank=True, null=True) status = models.CharField(max_length=200, null=True, choices=STATUS) quantity = models.IntegerField(default=0, null=True, blank=True) - date_created = models.DateTimeField(auto_now_add=True, null=True, blank=True) + date = models.DateTimeField(auto_now=0) + def __str__(self): return self.product.name \ No newline at end of file diff --git a/EDMS/shoppingCart/templates/shoppingCart/allocate.html b/EDMS/shoppingCart/templates/shoppingCart/allocate.html index fc927e1..62ebb1d 100644 --- a/EDMS/shoppingCart/templates/shoppingCart/allocate.html +++ b/EDMS/shoppingCart/templates/shoppingCart/allocate.html @@ -8,7 +8,7 @@ - + {% endblock content %} diff --git a/EDMS/shoppingCart/templates/shoppingCart/delete_item.html b/EDMS/shoppingCart/templates/shoppingCart/delete_item.html deleted file mode 100644 index 8ff1d72..0000000 --- a/EDMS/shoppingCart/templates/shoppingCart/delete_item.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends 'shoppingCart/store_dashBoard.html' %} -{% block content %} - - -
-
-
-
- -

Are you sure you want to delete "{{item}}"?

-
- {% csrf_token %} - Go back - - -
-
-
-
- - -{% endblock content %} \ No newline at end of file diff --git a/EDMS/shoppingCart/templates/shoppingCart/order_form.html b/EDMS/shoppingCart/templates/shoppingCart/order_form.html deleted file mode 100644 index 5105c24..0000000 --- a/EDMS/shoppingCart/templates/shoppingCart/order_form.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends 'shoppingCart/store_dashBoard.html' %} -{% load static %} -{% block content %} -{% load widget_tweaks %} - - -
-
-
- {% if action == 'create' %} -

Create Shop Order

- {% elif action == 'update' %} -

Update Shop Order

- {% endif %} - -
-
-
- -
-
-
-
- {% csrf_token %} - {% for field in form %} - {{field.label}} - {{field|add_class:'form-control'}} - - {% endfor %} -
- -
-
-
-
- -{% endblock %} \ No newline at end of file diff --git a/EDMS/shoppingCart/templates/shoppingCart/status_row.html b/EDMS/shoppingCart/templates/shoppingCart/status_row.html index 096fdef..a870741 100644 --- a/EDMS/shoppingCart/templates/shoppingCart/status_row.html +++ b/EDMS/shoppingCart/templates/shoppingCart/status_row.html @@ -3,7 +3,7 @@
-
+
Total Stores Available
@@ -16,12 +16,12 @@
-
+
Orders Delivered To Stores
-
{{delivered}}
+

{{delivered}}

diff --git a/EDMS/shoppingCart/templates/shoppingCart/store.html b/EDMS/shoppingCart/templates/shoppingCart/store.html deleted file mode 100644 index 620423a..0000000 --- a/EDMS/shoppingCart/templates/shoppingCart/store.html +++ /dev/null @@ -1,67 +0,0 @@ -{% extends 'shoppingCart/store_dashBoard.html' %} -{% block content %} -{% load widget_tweaks %} - - -
- -
-
-
-
-
Store: {{store.name}}
-
- Update Store - Delete Store - -
-
- -
-
-
Store Information
-
-

Name: {{store.name}}

-

Location: {{store.location}}

-

Capacity: {{store.name}}

-

Available: {{store.location}}

-
-
- -
-
-
Total Stores Orders
-
-

{{total_store_orders}}

-
-
-
-
- -
-
-
-
-
- {% for field in filter.form %} - {{field.label}} - {{field|add_class:'form-control-sm'}} - {% endfor %} - -
-
-
- -
-
- - - {% endfor %} - -
-
-
- - - -{% endblock content %} \ No newline at end of file diff --git a/EDMS/shoppingCart/templates/shoppingCart/store_dashBoard.html b/EDMS/shoppingCart/templates/shoppingCart/store_dashBoard.html index e1c7fb3..00b11f5 100644 --- a/EDMS/shoppingCart/templates/shoppingCart/store_dashBoard.html +++ b/EDMS/shoppingCart/templates/shoppingCart/store_dashBoard.html @@ -17,30 +17,27 @@ {% include 'shoppingCart/status_row.html' %} -
+
-
+
-
+
Create Store - +
- - {% for store in store %} + - - - - + + {% endfor %} @@ -48,32 +45,31 @@ -
-
+ + +
Name LocationAvailableSent

{{store}}

{{store.location}}

{{store.available}}{{store.capacity}}

{{store}}

{{store.location}}

+
- - - - - - - - - + + + + + - {% for storeorder in storeorder %} + {% for i in storeorder %} + - - - - - - - - + + + + + + + {% endfor %}
StoresProductsOrdersQuantityStatusAllocatedUpdateRemoveSTORE ORDERSTOREQUANTITYDATESTATUS
{{store}}{{store.product}}{{store.storeorder}}{{store.quantity}}{{store.status}}{{store.date_created}}UpdateCancel

{{i}}

{{i.store}}

{{i.quantity}}

{{i.date}}

{{i.status}}

{{i.date_created}}

@@ -82,7 +78,11 @@
{% endblock content %} -
+ + + + +
diff --git a/EDMS/shoppingCart/views.py b/EDMS/shoppingCart/views.py index c2b8bc5..ed4c884 100644 --- a/EDMS/shoppingCart/views.py +++ b/EDMS/shoppingCart/views.py @@ -47,11 +47,15 @@ def updateItem(request): print('ProductID: ', productId, 'Action:',action) return JsonResponse('item added', safe=False) -def store_dashBoard(request): +def store_dashBoard(request): store = Store.objects.all() total_stores = store.count() + products = Product.objects.all() + delivered = StoreOrder.objects.filter(status='Delivered').count() - context = {'store': store, 'total_stores':total_stores, } + storeorder = StoreOrder.objects.all() + + context = {'store': store, 'total_stores':total_stores,'products':products, 'storeorder':storeorder, 'delivered':delivered, } return render(request, 'ShoppingCart/store_dashBoard.html', context) def products(request):