Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/6 product types api #14

Merged
merged 14 commits into from
Sep 3, 2024
Merged

Feature/6 product types api #14

merged 14 commits into from
Sep 3, 2024

Conversation

Floris272
Copy link
Collaborator

Adds initial drf setup, endpoints for the product_types app and api tests

@Floris272 Floris272 linked an issue Aug 22, 2024 that may be closed by this pull request
4 tasks
@Floris272 Floris272 requested a review from swrichards August 22, 2024 14:17
.github/workflows/generate-postman-collection.yml Outdated Show resolved Hide resolved
src/open_producten/conf/base.py Outdated Show resolved Hide resolved
@@ -32,10 +32,8 @@ class Tag(BaseModel):
)
type = models.ForeignKey(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nog heel even voor mijn begrip: wat moet ik me voorstellen bij een TagType? Voelt een beetje als een tag op een tag, was even benieuwd naar de use-case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja klopt dat is het eigenlijk ook. Het komt vanuit Open Inwoner omdat het mij handig leek om de modellen zo veel mogelijk overeen te laten komen voor de integratie straks. Maar er zou ook gewoon één type aan alle tags vanuit Open producten worden gelinkt waardoor het hier weg zou kunnen.

@transaction.atomic()
def create(self, validated_data):
options = validated_data.pop("options")
product_type = validated_data.pop("product_type")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dit veld staat wel vermeld onder exclude: is veld wel definieren met write_only=True misschien leesbaarder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er zijn een twee product_type attributes, price zelf heeft product_type maar die worden geexclude omdat het al genest is via product_type. de product_type die hier uit de validated_data wordt gehaald word via perform_create in ProductTypeChildViewSet toegevoegd en is de parent.

Ik zou het liever niet willen hernoemen omdat ik bang ben dat ik dan alle andere serializers (die geen create/update override nodig hebben) die dit ook gebruiken moet aanpassen.

src/open_producten/producttypes/serializers/children.py Outdated Show resolved Hide resolved
src/open_producten/urls.py Outdated Show resolved Hide resolved
@Floris272
Copy link
Collaborator Author

Ik heb ook aangepast dat alle errors in de price, category en product_type serializers eerst samengevoegd worden en dan pas worden teruggestuurd naar de client.

Copy link
Contributor

@swrichards swrichards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ziet er goed uit, nog een klein dingetje, dan kan ik deze snel approven.

src/open_producten/utils/serializers.py Outdated Show resolved Hide resolved
Copy link
Contributor

@swrichards swrichards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional nitpick left, but otherwise LGTM

src/open_producten/utils/tests/test_serializer_utils.py Outdated Show resolved Hide resolved
@Floris272 Floris272 force-pushed the feature/6-product-types-api branch from 0789364 to 8235e09 Compare September 3, 2024 10:27
@Floris272 Floris272 force-pushed the feature/6-product-types-api branch from 8235e09 to be49dd2 Compare September 3, 2024 12:06
@Floris272 Floris272 merged commit 478a09a into main Sep 3, 2024
10 checks passed
@Floris272 Floris272 deleted the feature/6-product-types-api branch November 8, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

product type crud
2 participants