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
Eylultuncel homework 3 #76
Open
eylultuncel
wants to merge
13
commits into
upy:main
Choose a base branch
from
eylultuncel:eylultuncel-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
13 commits
Select commit
Hold shift + click to select a range
3bff20f
added product models
upy 851428d
added locale files
upy b67c189
added French language
upy 33168c9
Merge remote-tracking branch 'origin/main' into main
eylultuncel 39b5dc6
Merge branch 'main' of https://github.com/eylultuncel/bootcamp into main
eylultuncel 1336d44
product views and serializers added
eylultuncel 69756c8
payments views and serializers added
eylultuncel 347f48b
orders views and serializers added
eylultuncel 741f2cb
customers views and serializers added
eylultuncel fc7cc6d
baskets views and serializers added
eylultuncel c357a3b
pagination added
eylultuncel 2fec279
filters added to all apps
eylultuncel 0f5e0f6
migration files -after merge all migrations deleted and migrate again…
eylultuncel 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,19 @@ | ||
| from django_filters import rest_framework as filters | ||
| from django.utils.translation import gettext_lazy as _ | ||
|
|
||
| from baskets.models import Basket, BasketItem | ||
|
|
||
|
|
||
| class BasketFilter(filters.FilterSet): | ||
| status = filters.CharFilter(label=_("Status"), lookup_expr="icontains") | ||
|
|
||
| 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
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
| # Generated by Django 3.2.9 on 2021-12-08 13:35 | ||
|
|
||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| initial = True | ||
|
|
||
| dependencies = [ | ||
| ('baskets', '0001_initial'), | ||
| migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='basket', | ||
| name='customer', | ||
| field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Customer'), | ||
| ), | ||
| ] |
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 rest_framework import serializers | ||
|
|
||
| from baskets.models import Basket, BasketItem | ||
| from customers.serializers import CustomerSerializer | ||
| from products.serializers import ProductDetailedSerializer | ||
|
|
||
|
|
||
| class BasketSerializer(serializers.ModelSerializer): | ||
|
|
||
| class Meta: | ||
| model = Basket | ||
| fields = ("customer", "status") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id eklememizde fayda var. |
||
|
|
||
|
|
||
| class BasketDetailedSerializer(serializers.ModelSerializer): | ||
| customer = CustomerSerializer() | ||
|
|
||
| class Meta: | ||
| model = Basket | ||
| fields = ("customer", "status") | ||
|
|
||
|
|
||
| class BasketItemSerializer(serializers.ModelSerializer): | ||
|
|
||
| class Meta: | ||
| model = BasketItem | ||
| fields = ("basket", "product", "quantity", "price") | ||
|
|
||
|
|
||
| class BasketItemDetailedSerializer(serializers.ModelSerializer): | ||
| basket = BasketDetailedSerializer() | ||
| product = ProductDetailedSerializer() | ||
|
|
||
| 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 |
|---|---|---|
| @@ -1,3 +1,27 @@ | ||
| from django.shortcuts import render | ||
| from rest_framework import viewsets | ||
|
|
||
| # Create your views here. | ||
| from core.mixins import DetailedViewSetMixin | ||
| from baskets.filters import BasketFilter, BasketItemFilter | ||
| from baskets.models import Basket, BasketItem | ||
| from baskets.serializers import BasketSerializer, BasketDetailedSerializer, \ | ||
| BasketItemSerializer, BasketItemDetailedSerializer | ||
|
|
||
|
|
||
| class BasketViewSet(DetailedViewSetMixin, viewsets.ModelViewSet): | ||
| queryset = Basket.objects.all() | ||
| serializer_class = BasketSerializer | ||
| filterset_class = BasketFilter | ||
| serializer_action_classes = { | ||
| "detailed_list": BasketDetailedSerializer, | ||
| "detailed": BasketDetailedSerializer, | ||
| } | ||
|
|
||
|
|
||
| class BasketItemViewSet(DetailedViewSetMixin, viewsets.ModelViewSet): | ||
| queryset = BasketItem.objects.all() | ||
| serializer_class = BasketItemSerializer | ||
| filterset_class = BasketItemFilter | ||
| serializer_action_classes = { | ||
| "detailed_list": BasketItemDetailedSerializer, | ||
| "detailed": BasketItemDetailedSerializer, | ||
| } |
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,38 @@ | ||
| from django.utils.translation import gettext_lazy as _ | ||
| from django_filters import rest_framework as filters | ||
|
|
||
| from customers.models import Customer, City, Country, Address | ||
|
|
||
|
|
||
| class CustomerFilter(filters.FilterSet): | ||
| first_name = filters.CharFilter(label=_("First Name"), lookup_expr="icontains") | ||
| last_name = filters.CharFilter(label=_("Last Name"), lookup_expr="icontains") | ||
| email = filters.CharFilter(label=_("Email"), lookup_expr="icontains") | ||
|
|
||
| class Meta: | ||
| model = Customer | ||
| fields = ("first_name", "last_name", "email") | ||
|
|
||
|
|
||
| class CityFilter(filters.FilterSet): | ||
| name = filters.CharFilter(label=_("Name"), lookup_expr="icontains") | ||
|
|
||
| class Meta: | ||
| model = City | ||
| fields = ("name", "country") | ||
|
|
||
|
|
||
| class CountryFilter(filters.FilterSet): | ||
| name = filters.CharFilter(label=_("Name"), lookup_expr="icontains") | ||
|
|
||
| class Meta: | ||
| model = Country | ||
| fields = ("name",) | ||
|
|
||
|
|
||
| class AddressFilter(filters.FilterSet): | ||
| name = filters.CharFilter(label=_("Name"), lookup_expr="icontains") | ||
|
|
||
| class Meta: | ||
| model = Address | ||
| fields = ("name", "full_name", "phone", "district", "zipcode", "customer", "city") |
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.
migration dosyalarina ozel durumlar haric dokunmamamizda fayda var.