Skip to content

Commit

Permalink
Merge pull request #47 from subodh30/apartments_search_functionality
Browse files Browse the repository at this point in the history
added apartments search functionality
  • Loading branch information
subodh30 authored Oct 9, 2022
2 parents ef80de0 + eaa405c commit 72c15df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion housing/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_delete_owner(self):
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
self.assertEqual(Owner.objects.count(), 0)


class InterestedTests(APITestCase, TestCase):

@classmethod
Expand Down Expand Up @@ -162,4 +163,4 @@ def test_delete_flat(self):
response = self.client.delete(url, data, format='json')

self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
self.assertEqual(Flat.objects.count(), 0)
self.assertEqual(Flat.objects.count(), 0)
6 changes: 4 additions & 2 deletions housing/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# router.register(r'flats', views.FlatViewSet, basename="flat_viewset")
# router.register(r'owners', views.OwnerViewSet, basename="owner_viewset")
# router.register(r'interests', views.InterestedViewSet, basename="interests_viewset")
router.register(r'apartments', views.ApartmentViewSet, basename="apartment_viewset")
# router.register(r'apartments', views.ApartmentViewSet, basename="apartment_viewset")
# router.register(r'lease', views.LeaseViewSet, basename='lease_viewset')

urlpatterns = [
Expand All @@ -21,5 +21,7 @@
path('lease/<str:pk>', views.LeaseViewSet.as_view()),
path('interests', views.InterestedViewSet.as_view()),
path('interests/<str:pk>', views.InterestedViewSet.as_view()),

path('apartments', views.ApartmentViewSet.as_view()),
path('apartments/<str:pk>', views.ApartmentViewSet.as_view()),

]
4 changes: 3 additions & 1 deletion housing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class LeaseViewSet(generics.ListCreateAPIView, generics.RetrieveUpdateDestroyAPI
serializer_class = serializers.LeaseSerializer


class ApartmentViewSet(viewsets.ModelViewSet):
class ApartmentViewSet(generics.ListCreateAPIView, generics.RetrieveUpdateDestroyAPIView):
search_fields = ['address', 'facilities', 'owner_id']
filter_backends = (filters.SearchFilter,)
queryset = models.Apartment.objects.all()
serializer_class = serializers.ApartmentSerializer

Expand Down

0 comments on commit 72c15df

Please sign in to comment.