Skip to content

Commit

Permalink
Fix api spec errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Aug 20, 2024
1 parent 2af74f8 commit 8eebb0f
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 79 deletions.
10 changes: 5 additions & 5 deletions src/open_producten/producttypes/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@
ProductTypesRouter = DefaultRouter()
ProductTypesRouter.register("producttypes", ProductTypeViewSet, basename="producttype")
ProductTypesRouter.register(
"producttypes/(?P<id>[^/.]+)/links",
"producttypes/(?P<product_type_id>[^/.]+)/links",
ProductTypeLinkViewSet,
basename="producttype-link",
)
ProductTypesRouter.register(
"producttypes/(?P<id>[^/.]+)/prices",
"producttypes/(?P<product_type_id>[^/.]+)/prices",
ProductTypePriceViewSet,
basename="producttype-price",
)
ProductTypesRouter.register(
"producttypes/(?P<id>[^/.]+)/questions",
"producttypes/(?P<product_type_id>[^/.]+)/questions",
ProductTypeQuestionViewSet,
basename="producttype-question",
)
ProductTypesRouter.register(
"producttypes/(?P<id>[^/.]+)/fields",
"producttypes/(?P<product_type_id>[^/.]+)/fields",
ProductTypeFieldViewSet,
basename="producttype-field",
)

ProductTypesRouter.register("categories", CategoryViewSet, basename="category")
ProductTypesRouter.register(
"categories/(?P<id>[^/.]+)/questions",
"categories/(?P<category_id>[^/.]+)/questions",
CategoryQuestionViewSet,
basename="category-question",
)
9 changes: 4 additions & 5 deletions src/open_producten/producttypes/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.shortcuts import get_object_or_404

from rest_framework.viewsets import ModelViewSet

from open_producten.producttypes.models import (
Expand Down Expand Up @@ -33,11 +32,11 @@ class ProductTypeViewSet(BaseModelViewSet):
class ProductTypeChildViewSet(BaseModelViewSet):

def get_queryset(self):
return self.queryset.filter(product_type_id=self.kwargs["id"])
return self.queryset.filter(product_type_id=self.kwargs["product_type_id"])

def perform_create(self, serializer):
serializer.save(
product_type=get_object_or_404(ProductType, id=self.kwargs["id"])
product_type=get_object_or_404(ProductType, id=self.kwargs["product_type_id"])
)


Expand Down Expand Up @@ -70,10 +69,10 @@ class CategoryViewSet(BaseModelViewSet):
class CategoryChildViewSet(BaseModelViewSet):

def get_queryset(self):
return self.queryset.filter(category_id=self.kwargs["id"])
return self.queryset.filter(category_id=self.kwargs["category_id"])

def perform_create(self, serializer):
serializer.save(category=get_object_or_404(Category, id=self.kwargs["id"]))
serializer.save(category=get_object_or_404(Category, id=self.kwargs["category_id"]))


class CategoryQuestionViewSet(CategoryChildViewSet):
Expand Down
Loading

0 comments on commit 8eebb0f

Please sign in to comment.