emile 1 year ago
parent f3159b784b
commit 74b03429a9

@ -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:

@ -37,49 +37,25 @@
<!-- TABLE BODY -->
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">
<p class="text-slate-800">1</p>
</td>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">
<p class="text-slate-800">Standard Osimenu</p>
</td>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">
<p class="text-slate-800">$169</p>
</td>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300 bg-yellow-500">
<p class="text-white">Pending</p>
</td>
<td class="px-6 py-4">
<div class="w-full flex justify-center items-center">
<button class="flex justify-center items-center gap-2 px-3 py-1 rounded-md bg-osiblue text-white border border-osiblue cursor-pointer hover:bg-white hover:text-osiblue duration-300">
Receipt
<img src="{% static 'images/icons/download.png' %}" class="w-[28px]">
</button>
</div>
</td>
</tr>
{% for order in orders %}
<tr>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">
<p class="text-slate-800">3</p>
<p class="text-slate-800">{{order.order_id}}</p>
</td>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">
<p class="text-slate-800">Premium Osimenu</p>
{% for item in order.orderitem_set.all %}
<p class="text-slate-800">{{item.item.title}}</p>
{% endfor %}
</td>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">
<p class="text-slate-800">$200</p>
<p class="text-slate-800">${{order.get_cart_total}}</p>
</td>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300 bg-green-700">
<p class="text-white">Completed</p>
<p class="text-white">{{order.status}}</p>
</td>
<td class="px-6 py-4">
@ -91,6 +67,7 @@
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

@ -34,7 +34,7 @@
</div>
<div class="w-full grid grid-cols-3 gap-5 mt-20">
<div class="w-full grid grid-cols-3 gap-5 mt-5">
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-t-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-3xl text-center">Basic</p>
@ -46,11 +46,6 @@
</div>
<div class="relative">
<div
class="w-full px-5 py-3 text-white text-center font-semibold text-xl bg-osiblue rounded-t-md absolute top-[-50px]">
<p>Best Value</p>
</div>
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-b-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-3xl text-center">Standard</p>
@ -137,7 +132,7 @@
</div>
<div class="w-full grid grid-cols-3 gap-5 mt-20">
<div class="w-full grid grid-cols-3 gap-5 mt-5">
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-t-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-3xl text-center">Shared Basic</p>
@ -150,10 +145,6 @@
</div>
<div class="relative">
<div
class="w-full px-5 py-3 text-white text-center font-semibold text-xl bg-osiblue rounded-t-md absolute top-[-50px]">
<p>Best Value</p>
</div>
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-b-md bg-white">
@ -192,7 +183,7 @@
</div>
<div class="w-full grid grid-cols-4 gap-5 mt-20">
<div class="w-full grid grid-cols-4 gap-5 mt-5">
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-t-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-3xl text-center">OSICLOUD 1</p>
@ -205,10 +196,6 @@
</div>
<div class="relative">
<div
class="w-full px-5 py-3 text-white text-center font-semibold text-xl bg-osiblue rounded-t-md absolute top-[-50px]">
<p>Best Value</p>
</div>
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-b-md bg-white">
@ -257,7 +244,7 @@
</div>
<div class="w-full grid grid-cols-4 gap-5 mt-20">
<div class="w-full grid grid-cols-4 gap-5 mt-5">
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-t-md bg-white">
<p class="text-secondosiblue uppercase font-poppinsBold text-3xl text-center">DEDICATED 1</p>
@ -270,10 +257,6 @@
</div>
<div class="relative">
<div
class="w-full px-5 py-3 text-white text-center font-semibold text-xl bg-osiblue rounded-t-md absolute top-[-50px]">
<p>Best Value</p>
</div>
<div
class="w-full p-9 border border-gray-200 flex flex-col items-center gap-5 rounded-b-md bg-white">

@ -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 = {
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:

Binary file not shown.
Loading…
Cancel
Save