Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Aug 22, 2024
1 parent 78feb8c commit a4d6b66
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/open_producten/producttypes/serializers/category.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rest_framework import serializers

from open_producten.producttypes.models import Category, ProductType

from .children import QuestionSerializer, UpnSerializer


Expand Down Expand Up @@ -48,7 +49,9 @@ def create(self, validated_data):

def update(self, instance, validated_data):
product_types = validated_data.pop("product_type_ids", None)
parent_category = validated_data.pop("parent_category", "ignore") # None is a valid value
parent_category = validated_data.pop(
"parent_category", "ignore"
) # None is a valid value

if parent_category != "ignore":
instance_parent = instance.get_parent()
Expand Down
23 changes: 13 additions & 10 deletions src/open_producten/producttypes/tests/api/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
from open_producten.producttypes.models import Category, Link
from open_producten.producttypes.tests.factories import (
CategoryFactory,
ProductTypeFactory, QuestionFactory,
ProductTypeFactory,
QuestionFactory,
)
from open_producten.utils.tests.test_cases import BaseApiTestCase


def category_to_dict(category):
category_dict = model_to_dict(category, exclude=("path", "depth", "numchild")) | {"id": str(category.id)}
category_dict["questions"] = [model_to_dict(question) for question in category.questions.all()]
category_dict["product_types"] = [model_to_dict(product_type) for product_type in category.product_types.all()]
category_dict["created_on"] = str(
category.created_on.astimezone().isoformat()
)
category_dict["updated_on"] = str(
category.updated_on.astimezone().isoformat()
)
category_dict = model_to_dict(category, exclude=("path", "depth", "numchild")) | {
"id": str(category.id)
}
category_dict["questions"] = [
model_to_dict(question) for question in category.questions.all()
]
category_dict["product_types"] = [
model_to_dict(product_type) for product_type in category.product_types.all()
]
category_dict["created_on"] = str(category.created_on.astimezone().isoformat())
category_dict["updated_on"] = str(category.updated_on.astimezone().isoformat())
return category_dict


Expand Down
3 changes: 0 additions & 3 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 @@ -37,8 +36,6 @@ def get_queryset(self):
def perform_create(self, serializer):
serializer.save(product_type=self.get_product_type())

# TODO perform_update? delete?


class ProductTypeLinkViewSet(ProductTypeChildViewSet):
queryset = Link.objects.all()
Expand Down

0 comments on commit a4d6b66

Please sign in to comment.