This repository was archived by the owner on May 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Utkuaysev homework 3 #85
Open
victoraysev
wants to merge
3
commits into
upy:main
Choose a base branch
from
victoraysev:utkuaysev-homework-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from django_filters import rest_framework as filters | ||
|
|
||
| from baskets.models import Basket, BasketItem | ||
|
|
||
|
|
||
| class BasketFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = Basket | ||
| fields = ("customer", "status") | ||
|
|
||
|
|
||
| class BasketItemFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = BasketItem | ||
| fields = ("basket", "product", "quantity", "price") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| from rest_framework import serializers | ||
|
|
||
| from baskets.models import * | ||
| from customers.serializers import CustomerSerializer | ||
|
|
||
|
|
||
| class BasketSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Basket | ||
| fields = "id", "customer", "status", "created_at", "modified_at" | ||
|
|
||
|
|
||
| class BasketItemSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = BasketItem | ||
| fields = "id", "basket", "product", "quantity", "price" | ||
|
|
||
|
|
||
| class BasketDetailedSerializer(serializers.ModelSerializer): | ||
| customer = CustomerSerializer() | ||
| basket_items = BasketSerializer(many=True) | ||
|
|
||
| class Meta: | ||
| model = Basket | ||
| fields = "id", "customer", "status", "created_at", "modified_at" | ||
|
|
||
|
|
||
| class BasketItemDetailedSerializer(serializers.ModelSerializer): | ||
| basket = BasketSerializer() | ||
|
|
||
| class Meta: | ||
| model = BasketItem | ||
| fields = "id", "basket", "product", "quantity", "price" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,23 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views here. | ||
| # from rest_framework import viewsets | ||
| # | ||
| # from core.mixins import DetailedViewSetMixin | ||
| # from baskets.filters import BasketFilter | ||
| # from baskets.filters import BasketItemFilter | ||
| # from baskets.models import BasketItem, Basket | ||
| # from products.serializers import ProductSerializer, CategorySerializer, \ | ||
| # ProductDetailedSerializer | ||
| # | ||
| # | ||
| # class ProductViewSet(DetailedViewSetMixin, viewsets.ModelViewSet): | ||
| # queryset = Product.objects.all() | ||
| # serializer_class = ProductSerializer | ||
| # filterset_class = ProductFilter | ||
| # serializer_action_classes = { | ||
| # "detailed_list": ProductDetailedSerializer, | ||
| # "detailed": ProductDetailedSerializer, | ||
| # } | ||
| # | ||
| # | ||
| # class CategoryViewSet(viewsets.ModelViewSet): | ||
| # queryset = Category.objects.all() | ||
| # serializer_class = CategorySerializer | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from django_filters import rest_framework as filters | ||
|
|
||
| from customers.models import City, Country, Customer, get_all_customer_attrs, Address, get_all_address_attrs | ||
|
|
||
|
|
||
| class CityFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = City | ||
| fields = ("name", "country") | ||
|
|
||
|
|
||
| class CountryFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = Country | ||
| fields = ("name",) | ||
|
|
||
|
|
||
| class CustomerFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = Customer | ||
| fields = get_all_customer_attrs() | ||
|
|
||
|
|
||
| class AddressFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = Address | ||
| fields = get_all_address_attrs() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| from django.db.transaction import atomic | ||
| from rest_framework import serializers | ||
|
|
||
| from baskets.serializers import BasketSerializer | ||
| from core.models import get_all_base_abstract_model_attrs | ||
| from customers.models import * | ||
|
|
||
|
|
||
| class CitySerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = City | ||
| fields = "name", | ||
|
|
||
|
|
||
| class CountrySerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Country | ||
| fields = "name", "city" | ||
|
|
||
|
|
||
| class CustomerSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Customer | ||
| fields = get_all_customer_attrs() + ("id") + get_all_base_abstract_model_attrs | ||
|
|
||
|
|
||
| class AddressSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Address | ||
| fields = ("id",) + get_all_customer_attrs() + get_all_base_abstract_model_attrs() | ||
|
|
||
|
|
||
| class DetailedCustomerSerializer(serializers.ModelSerializer): | ||
| addresses = AddressSerializer(many=True) | ||
| baskets = BasketSerializer(many=True) | ||
|
|
||
| class Meta: | ||
| model = Address | ||
| fields = ("id",) + get_all_customer_attrs() + get_all_base_abstract_model_attrs() | ||
|
|
||
|
|
||
| class DetailedAddressSerializer(serializers.ModelSerializer): | ||
| customer = CustomerSerializer() | ||
|
|
||
| class Meta: | ||
| model = Address | ||
| fields = ("id",) + get_all_customer_attrs() + get_all_base_abstract_model_attrs() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from django_filters import rest_framework as filters | ||
|
|
||
| from customers.models import City, Country, Customer, get_all_customer_attrs, Address, get_all_address_attrs | ||
| from orders.models import BillingAddress, get_all_billing_address_attrs, ShippingAddress, \ | ||
| get_all_shipping_address_attrs, get_all_order_bank_account_attrs, OrderBankAccount, Order, get_all_order_attrs, \ | ||
| OrderItem, get_all_order_item_attrs | ||
|
|
||
|
|
||
| class BillingAddressFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = BillingAddress | ||
| fields = get_all_billing_address_attrs() | ||
|
|
||
|
|
||
| class ShippingAddressFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = ShippingAddress | ||
| fields = get_all_shipping_address_attrs() | ||
|
|
||
|
|
||
| class OrderBankAccountFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = OrderBankAccount | ||
| fields = get_all_order_bank_account_attrs() | ||
|
|
||
|
|
||
| class OrderFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = Order | ||
| fields = get_all_order_attrs() | ||
|
|
||
|
|
||
| class OrderItemFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = OrderItem | ||
| fields = get_all_order_item_attrs() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| from rest_framework import serializers | ||
|
|
||
| from core.models import get_all_base_abstract_model_attrs | ||
| from customers.serializers import CustomerSerializer | ||
| from orders.models import * | ||
|
|
||
|
|
||
| class BillingAddressSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = BillingAddress | ||
| fields = get_all_billing_address_attrs() + get_all_base_abstract_model_attrs() + ("id",) | ||
|
|
||
|
|
||
| class ShippingAddressSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = ShippingAddress | ||
| fields = get_all_shipping_address_attrs() + get_all_base_abstract_model_attrs() + "id" | ||
|
|
||
|
|
||
| class OrderBankAccountSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = OrderBankAccount | ||
| fields = get_all_order_bank_account_attrs() + get_all_base_abstract_model_attrs() + "id" | ||
|
|
||
|
|
||
| class OrderSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Order | ||
| fields = get_all_order_attrs() + get_all_base_abstract_model_attrs() + "id" | ||
|
|
||
|
|
||
| class OrderItemSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = OrderItem | ||
| fields = get_all_order_item_attrs() + get_all_base_abstract_model_attrs() + "id" | ||
|
|
||
|
|
||
| class OrderBankAccountDetailedSerializer(serializers.ModelSerializer): | ||
| order = OrderSerializer() | ||
|
|
||
| class Meta: | ||
| model = OrderBankAccount | ||
| fields = get_all_order_bank_account_attrs() + get_all_base_abstract_model_attrs() + "id" | ||
|
|
||
|
|
||
| class OrderDetailedSerializer(serializers.ModelSerializer): | ||
| order_bank_accounts = OrderBankAccountSerializer(many=True) | ||
| customer = CustomerSerializer() | ||
| billing_address = BillingAddressSerializer() | ||
| shipping_address = ShippingAddressSerializer() | ||
| order_items = OrderItemSerializer(many=True) | ||
|
|
||
| class Meta: | ||
| model = Order | ||
| fields = get_all_order_attrs() + get_all_base_abstract_model_attrs() + "id" | ||
|
|
||
|
|
||
| class OrderItemSerializer(serializers.ModelSerializer): | ||
| order = OrderSerializer() | ||
|
|
||
| class Meta: | ||
| model = OrderItem | ||
| fields = get_all_order_item_attrs() + get_all_base_abstract_model_attrs() + "id" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from django_filters import rest_framework as filters | ||
|
|
||
| from customers.models import City, Country, Customer, get_all_customer_attrs, Address, get_all_address_attrs | ||
| from orders.models import BillingAddress, get_all_billing_address_attrs, ShippingAddress, \ | ||
| get_all_shipping_address_attrs, get_all_order_bank_account_attrs, OrderBankAccount, Order, get_all_order_attrs, \ | ||
| OrderItem, get_all_order_item_attrs | ||
|
|
||
|
|
||
| class BillingAddressFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = BillingAddress | ||
| fields = get_all_billing_address_attrs() | ||
|
|
||
|
|
||
| class ShippingAddressFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = ShippingAddress | ||
| fields = get_all_shipping_address_attrs() | ||
|
|
||
|
|
||
| class OrderBankAccountFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = OrderBankAccount | ||
| fields = get_all_order_bank_account_attrs() | ||
|
|
||
|
|
||
| class OrderFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = Order | ||
| fields = get_all_order_attrs() | ||
|
|
||
|
|
||
| class OrderItemFilter(filters.FilterSet): | ||
| class Meta: | ||
| model = OrderItem | ||
| fields = get_all_order_item_attrs() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bu dosyanin tamamini neden yorum yaptik?