From b6f777e6feaba98ecb1653a6ef2cdfc87ece1b05 Mon Sep 17 00:00:00 2001 From: Jesse Zong Date: Sun, 24 Mar 2024 12:48:03 -0400 Subject: [PATCH] Allow users to see their own expired sublets --- backend/sublet/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/sublet/views.py b/backend/sublet/views.py index 8e2218ee..4fac30a5 100644 --- a/backend/sublet/views.py +++ b/backend/sublet/views.py @@ -140,7 +140,8 @@ def list(self, request, *args, **kwargs): beds = params.get("beds", None) baths = params.get("baths", None) - queryset = Sublet.objects.all().filter(expires_at__gte=timezone.now()) + queryset = self.get_queryset() + # Apply filters based on query parameters if title: queryset = queryset.filter(title__icontains=title) @@ -151,6 +152,8 @@ def list(self, request, *args, **kwargs): queryset = queryset.filter(amenities__name=amenity) if subletter.lower() == "true": queryset = queryset.filter(subletter=request.user) + else: + queryset = queryset.filter(expires_at__gte=timezone.now()) if starts_before: queryset = queryset.filter(start_date__lt=starts_before) if starts_after: