diff --git a/osinaweb/billing/__pycache__/models.cpython-310.pyc b/osinaweb/billing/__pycache__/models.cpython-310.pyc index 65d3e9aa..5bebdfb3 100644 Binary files a/osinaweb/billing/__pycache__/models.cpython-310.pyc and b/osinaweb/billing/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/billing/models.py b/osinaweb/billing/models.py index 597098bd..96805bb1 100644 --- a/osinaweb/billing/models.py +++ b/osinaweb/billing/models.py @@ -39,6 +39,12 @@ class Order(models.Model): order_id = models.CharField(max_length=100, null=True, blank=True) due_date = models.DateField(null=True) paid = models.BooleanField(null=True, default=False) + @property + def get_cart_total(self): + orderitems = self.orderitem_set.all() + total = sum([item.get_total for item in orderitems]) + return total + def save(self, *args, **kwargs): if not self.order_id: order_count = Order.objects.filter(customer=self.customer).count() @@ -53,6 +59,11 @@ class OrderItem(models.Model): purchased_at = models.DateField(null=True, blank=True) due_at = models.DateField(blank=True, null=True) recurring_cycle = models.ForeignKey(RecurringCycle, on_delete=models.SET_NULL, null=True, blank=True) + @property + def get_total(self): + total = self.item.amount + total = round(total, 2) + return total def save(self, *args, **kwargs): if self.purchased_at: try: diff --git a/osinaweb/customercore/__pycache__/urls.cpython-310.pyc b/osinaweb/customercore/__pycache__/urls.cpython-310.pyc index 851d795d..786b047b 100644 Binary files a/osinaweb/customercore/__pycache__/urls.cpython-310.pyc and b/osinaweb/customercore/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/customercore/__pycache__/views.cpython-310.pyc b/osinaweb/customercore/__pycache__/views.cpython-310.pyc index c4d49f55..a430825d 100644 Binary files a/osinaweb/customercore/__pycache__/views.cpython-310.pyc and b/osinaweb/customercore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/customercore/templates/listing_pages/customer-orders.html b/osinaweb/customercore/templates/listing_pages/customer-orders.html index a6c0804a..6832602c 100644 --- a/osinaweb/customercore/templates/listing_pages/customer-orders.html +++ b/osinaweb/customercore/templates/listing_pages/customer-orders.html @@ -37,49 +37,25 @@ - - -

1

- - - -

Standard Osimenu

- - - -

$169

- - - -

Pending

- - - -
- -
- - - + {% for order in orders %} -

3

+

{{order.order_id}}

-

Premium Osimenu

+ {% for item in order.orderitem_set.all %} +

{{item.item.title}}

+ {% endfor %} -

$200

+

${{order.get_cart_total}}

-

Completed

+

{{order.status}}

@@ -91,6 +67,7 @@ + {% endfor %} diff --git a/osinaweb/customercore/templates/listing_pages/products.html b/osinaweb/customercore/templates/listing_pages/products.html index 78698b55..495108a7 100644 --- a/osinaweb/customercore/templates/listing_pages/products.html +++ b/osinaweb/customercore/templates/listing_pages/products.html @@ -34,7 +34,7 @@ -
+

Basic

@@ -46,11 +46,6 @@
-
-

Best Value

-
-

Standard

@@ -137,7 +132,7 @@
-
+

Shared Basic

@@ -150,10 +145,6 @@
-
-

Best Value

-
@@ -192,7 +183,7 @@
-
+

OSICLOUD 1

@@ -205,10 +196,6 @@
-
-

Best Value

-
@@ -257,7 +244,7 @@
-
+

DEDICATED 1

@@ -270,10 +257,6 @@
-
-

Best Value

-
diff --git a/osinaweb/customercore/views.py b/osinaweb/customercore/views.py index 6c32de2f..74e0de5c 100644 --- a/osinaweb/customercore/views.py +++ b/osinaweb/customercore/views.py @@ -30,9 +30,12 @@ def all_products(request, *args, **kwargs): @customer_login_required def customer_orders(request, *args, **kwargs): + customer = request.user.customerprofile + orders = Order.objects.filter(customer=customer, status='Completed') + context = { - + 'orders': orders, } return render(request, 'listing_pages/customer-orders.html', context) @@ -171,8 +174,7 @@ def check_order_status(request, merchant_id, order_id): due_date = order_item.purchased_at + timedelta(days=recurring_cycle) order_item.due_at = due_date order_item.save() - return JsonResponse(order_details) - else: + return redirect('orders') error_message = 'Failed to retrieve order details: ' + response.text return JsonResponse({'error': error_message}, status=500) except Exception as e: diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 1c3ff48f..895117d6 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc index 7e1b2598..415500cd 100644 Binary files a/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc index 70597fa2..e983cd98 100644 Binary files a/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc differ