Skip to content

Commit

Permalink
filtered out expired events for order listing
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNyl committed Sep 26, 2023
1 parent 7ed7b77 commit 3f7843c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/content/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/payment/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3f7843c

Please sign in to comment.