Compare commits

..

No commits in common. "dfbbbb2b225d1951a4c3229179fc295665f414ea" and "6796922fe68f9856f1c2e4938c1aa51dceb9e915" have entirely different histories.

3 changed files with 2 additions and 13 deletions

View file

@ -5,7 +5,6 @@
### Fixed ### Fixed
- `GET /api/v1/stores/` — documented the `category`, `neighborhood`, `search`, `lat`, and `lng` query params for drf-spectacular so they render in swagger. The filtering itself already worked; only the OpenAPI schema was missing them (`apps/stores/views.py`). - `GET /api/v1/stores/` — documented the `category`, `neighborhood`, `search`, `lat`, and `lng` query params for drf-spectacular so they render in swagger. The filtering itself already worked; only the OpenAPI schema was missing them (`apps/stores/views.py`).
- `GET /api/v1/products/` — same issue: documented the existing `store`, `category`, and `search` query params for swagger (`apps/catalog/views.py`). - `GET /api/v1/products/` — same issue: documented the existing `store`, `category`, and `search` query params for swagger (`apps/catalog/views.py`).
- Cart items: `CartItemView` was registered on both `/api/v1/cart/items/` and `/api/v1/cart/items/{item_uuid}/`, so swagger showed POST/PATCH/DELETE on both paths — 3 of those 6 combinations crashed with a `TypeError` at runtime (`item_uuid` missing or unexpected). Split into `CartItemView` (POST only, list path) and `CartItemDetailView` (PATCH/DELETE only, detail path) so swagger only shows the combinations that actually work (`apps/orders/views.py`, `apps/orders/urls.py`).
### Added ### Added
- `GET /api/v1/cities/?search=` — search cities by name (`apps/locations/views.py`); previously no text search existed. - `GET /api/v1/cities/?search=` — search cities by name (`apps/locations/views.py`); previously no text search existed.

View file

@ -2,7 +2,6 @@ from django.urls import path
from rest_framework.routers import DefaultRouter from rest_framework.routers import DefaultRouter
from .views import ( from .views import (
CartItemDetailView,
CartItemView, CartItemView,
CartView, CartView,
CheckoutView, CheckoutView,
@ -24,5 +23,5 @@ urlpatterns = router.urls + [
path('checkout/', CheckoutView.as_view(), name='checkout'), path('checkout/', CheckoutView.as_view(), name='checkout'),
path('cart/', CartView.as_view(), name='cart'), path('cart/', CartView.as_view(), name='cart'),
path('cart/items/', CartItemView.as_view(), name='cart-items'), path('cart/items/', CartItemView.as_view(), name='cart-items'),
path('cart/items/<uuid:item_uuid>/', CartItemDetailView.as_view(), name='cart-item-detail'), path('cart/items/<uuid:item_uuid>/', CartItemView.as_view(), name='cart-item-detail'),
] ]

View file

@ -47,7 +47,7 @@ class CartView(APIView):
class CartItemView(APIView): class CartItemView(APIView):
"""Add a product line to the authenticated user's cart.""" """Add/update/remove a single product line in the authenticated user's cart."""
schema_tags = ['Cart'] schema_tags = ['Cart']
serializer_class = CartItemWriteSerializer serializer_class = CartItemWriteSerializer
@ -73,15 +73,6 @@ class CartItemView(APIView):
return Response(CartItemSerializer(item).data, status=status.HTTP_201_CREATED) return Response(CartItemSerializer(item).data, status=status.HTTP_201_CREATED)
class CartItemDetailView(APIView):
"""Update/remove a single product line in the authenticated user's cart."""
schema_tags = ['Cart']
serializer_class = CartItemWriteSerializer
permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements]
required_alternate_scopes = {}
@extend_schema(responses=CartItemSerializer) @extend_schema(responses=CartItemSerializer)
def patch(self, request, item_uuid): def patch(self, request, item_uuid):
item = get_object_or_404(CartItem, uuid=item_uuid, cart__user=request.user) item = get_object_or_404(CartItem, uuid=item_uuid, cart__user=request.user)