Skip to content

Commit

Permalink
Allow users to see their own expired sublets (#275)
Browse files Browse the repository at this point in the history
* Allow users to see their own expired sublets

* nit: change logic ordering
  • Loading branch information
dr-Jess authored Mar 24, 2024
1 parent 0905840 commit a4f5305
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/sublet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,21 @@ 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 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:
queryset = queryset.filter(address__icontains=address)
if amenities:
for amenity in amenities:
queryset = queryset.filter(amenities__name=amenity)
if subletter.lower() == "true":
queryset = queryset.filter(subletter=request.user)
if starts_before:
queryset = queryset.filter(start_date__lt=starts_before)
if starts_after:
Expand Down

0 comments on commit a4f5305

Please sign in to comment.