union favorites create/destroy in one endpoint
This commit is contained in:
parent
0f6786fb13
commit
7577ad330c
|
|
@ -13,6 +13,5 @@ urlpatterns = [
|
|||
name='create-comment'),
|
||||
path('<int:pk>/comment/<int:comment_id>/', views.EstablishmentCommentRUDView.as_view(),
|
||||
name='rud-comment'),
|
||||
path('<int:pk>/favorites/add/', views.EstablishmentFavoritesCreateView.as_view()),
|
||||
path('<int:pk>/favorites/delete/', views.EstablishmentFavoritesDestroyView.as_view()),
|
||||
path('<int:pk>/favorites/', views.EstablishmentFavoritesCreateDestroyView.as_view()),
|
||||
]
|
||||
|
|
@ -79,14 +79,10 @@ class EstablishmentCommentRUDView(generics.RetrieveUpdateDestroyAPIView):
|
|||
return comment_obj
|
||||
|
||||
|
||||
class EstablishmentFavoritesCreateView(generics.CreateAPIView):
|
||||
"""View for adding establishment to favorites."""
|
||||
class EstablishmentFavoritesCreateDestroyView(generics.CreateAPIView, generics.DestroyAPIView):
|
||||
"""View for create/destroy establishment from favorites."""
|
||||
serializer_class = serializers.EstablishmentFavoritesCreateSerializer
|
||||
|
||||
|
||||
class EstablishmentFavoritesDestroyView(generics.DestroyAPIView):
|
||||
"""View for destroy establishment from favorites."""
|
||||
|
||||
def get_object(self):
|
||||
"""
|
||||
Returns the object the view is displaying.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user