From 623076cb91d98d416986ee85376fc57f804bf564 Mon Sep 17 00:00:00 2001 From: Mads Nylund Date: Sun, 24 Sep 2023 13:14:42 +0200 Subject: [PATCH] filtered out expired events for order listing --- app/content/views/user.py | 6 ++++++ app/payment/models/order.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/content/views/user.py b/app/content/views/user.py index a0a7c6f82..7787b76f5 100644 --- a/app/content/views/user.py +++ b/app/content/views/user.py @@ -289,6 +289,12 @@ def get_user_events(self, request, *args, **kwargs): @action(detail=False, methods=["get"], url_path="me/payment_orders") def get_user_payment_orders(self, request, *args, **kwargs): payment_orders = request.user.orders.all() + print(payment_orders) + payment_orders = [ + order + for order in payment_orders + if (order.event and not order.event.expired) + ] return self.paginate_response( data=payment_orders, serializer=OrderListSerializer, diff --git a/app/payment/models/order.py b/app/payment/models/order.py index 31e9381d2..12dc3c823 100644 --- a/app/payment/models/order.py +++ b/app/payment/models/order.py @@ -32,8 +32,8 @@ class Meta: verbose_name_plural = "Orders" ordering = ("-created_at",) - def __str__(self): - return f"{self.order_id} {self.user} {self.event} {self.status} {self.expire_date}" + def __str__(self): + return f"{self.user.first_name} {self.user.last_name} - {self.status} - {self.created_at}" @property def expired(self):