From 0c885569e93651aa081c99508cfe38fdbd76afcd Mon Sep 17 00:00:00 2001 From: Jesse Zong Date: Sun, 24 Mar 2024 13:11:22 -0400 Subject: [PATCH] nit: change logic ordering --- backend/sublet/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/sublet/views.py b/backend/sublet/views.py index 4fac30a5..38623631 100644 --- a/backend/sublet/views.py +++ b/backend/sublet/views.py @@ -143,6 +143,11 @@ def list(self, request, *args, **kwargs): queryset = self.get_queryset() # Apply filters based on query parameters + + if subletter.lower() == "true": + queryset = queryset.filter(subletter=request.user) + else: + queryset = queryset.filter(expires_at__gte=timezone.now()) if title: queryset = queryset.filter(title__icontains=title) if address: @@ -150,10 +155,6 @@ def list(self, request, *args, **kwargs): if amenities: for amenity in amenities: 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: