From 0cf5ca5f4d9df19ca93b2aa95895d90782c6fc48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:35:54 +0300 Subject: [PATCH 01/14] add ShoppnigCart Order --- backend/orders/models.py | 99 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 backend/orders/models.py diff --git a/backend/orders/models.py b/backend/orders/models.py new file mode 100644 index 0000000..3d029b6 --- /dev/null +++ b/backend/orders/models.py @@ -0,0 +1,99 @@ +from django.core.validators import MinValueValidator, MaxValueValidator +from django.db import models + +from users.models import User +from products.models import Product + +SHOPPINGCART = (('Ordered', 'Передано в заказ'), ('In work','В работе')) + +STATUS = (('Ordered', 'Оформлен'), ('In processing', 'В обработке'), + ('Completed', 'Комплектуется'), + ('Gathered', 'Собран'),('In delivering', 'Передан в доставку'), + ('Delivered', 'Доставлен'), ('Completed', 'Завершен')) + +PAYMENT_METHODS = (('Cash', 'Наличные'), + ('By card on the website', 'Картой на сайте'), + ('In getting','При получении')) + +DELIVERY_METHOD = (('Point of delivery', 'Пункт выдачи'), + ('By courier', 'Курьером')) + + +class ShoppingCart(models.Model): + """Model for creating a shopping cart.""" + user = models.ForeignKey( + User, + on_delete=models.CASCADE, + related_name='shopping_carts', + verbose_name='Добавил в корзину' + ) + product = models.ForeignKey( + Product, + on_delete=models.CASCADE, + related_name='shopping_carts', + verbose_name='Продукт в корзине' + ) + quantity = models.IntegerField( + verbose_name='Количество товара', + validators=[ + MinValueValidator(1, 'Разрешены значения от 1 до 100'), + MaxValueValidator(10000, 'Разрешены значения от 1 до 100') + ] + ) + status = models.CharField( + max_length=50, + choices=SHOPPINGCART, + default='В работе' + ) + + class Meta: + verbose_name = 'Корзина' + verbose_name_plural = 'Корзина' + constraints = [ + models.UniqueConstraint( + fields=['user', 'product'], + name='unique_shopping_cart' + ) + ] + + +class Order(models.Model): + """Model for creating an order.""" + goods = models.ForeignKey( + ShoppingCart, + on_delete=models.CASCADE, + related_name='orders', + verbose_name='Покупки' + ) + date = models.DateField( + verbose_name='Дата оформления', + auto_now_add=True + ) + status = models.CharField( + max_length=50, + choices=STATUS, + default='Оформлен' + ) + payment_method = models.CharField( + max_length=50, + choices=PAYMENT_METHODS, + default='Картой на сайте' + ) + is_paid = models.BooleanField(default=False) + comment = models.TextField( + max_length=400, + blank=True + ) + delivery_method = models.CharField( + max_length=50, + choices=DELIVERY_METHOD, + default='Курьером' + ) + total_price = models.IntegerField( + default=0 + ) + + class Meta: + ordering = ['-date'] + verbose_name = 'Заказ' + verbose_name_plural = 'Заказы' From c8596e95efd412483cd0e281de896ee0a2502ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:36:01 +0300 Subject: [PATCH 02/14] add Order --- backend/good_food/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/good_food/settings.py b/backend/good_food/settings.py index 0ddfbd9..c315e68 100644 --- a/backend/good_food/settings.py +++ b/backend/good_food/settings.py @@ -51,6 +51,7 @@ "products.apps.ProductsConfig", "users.apps.UsersConfig", "api.apps.ApiConfig", + "orders.apps.OrdersConfig", "phonenumber_field", ] From 46a0ab09f2bfa791dab62b5346efe9bddac438a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:37:41 +0300 Subject: [PATCH 03/14] add shopping cart admin --- backend/orders/admin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 backend/orders/admin.py diff --git a/backend/orders/admin.py b/backend/orders/admin.py new file mode 100644 index 0000000..61a13a3 --- /dev/null +++ b/backend/orders/admin.py @@ -0,0 +1,12 @@ +from django.contrib import admin + +from orders.models import ShoppingCart, Order + + +@admin.register(ShoppingCart) +class ShoppingCartAdmin(admin.ModelAdmin): + list_display = ('id', 'user', 'product', 'quantity', 'status') + list_editable = ('user', 'product', 'quantity') + search_fields = ('user',) + + From f5bc9e2866f9573759523d3b413b89053a603837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:37:50 +0300 Subject: [PATCH 04/14] add orders --- backend/orders/apps.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 backend/orders/apps.py diff --git a/backend/orders/apps.py b/backend/orders/apps.py new file mode 100644 index 0000000..8ae0375 --- /dev/null +++ b/backend/orders/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class OrdersConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'orders' From 0a05da3e38a9e7510f3ce4560754de3ae80d51ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:37:58 +0300 Subject: [PATCH 05/14] add orders --- backend/orders/__init__.py | 0 backend/orders/migrations/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 backend/orders/__init__.py create mode 100644 backend/orders/migrations/__init__.py diff --git a/backend/orders/__init__.py b/backend/orders/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/orders/migrations/__init__.py b/backend/orders/migrations/__init__.py new file mode 100644 index 0000000..e69de29 From 8863bce879ae7758af1f0841d39733276a14f325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:44:26 +0300 Subject: [PATCH 06/14] add test data --- backend/data/category.csv | 10 +++ backend/data/products.csv | 4 + backend/data/users.csv | 7 ++ .../products/management/commands/load_data.py | 86 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 backend/data/category.csv create mode 100644 backend/data/products.csv create mode 100644 backend/data/users.csv create mode 100644 backend/products/management/commands/load_data.py diff --git a/backend/data/category.csv b/backend/data/category.csv new file mode 100644 index 0000000..b12b30f --- /dev/null +++ b/backend/data/category.csv @@ -0,0 +1,10 @@ +id,name,slug +1,Фрукты,fruts +2,Овощи,vegetables +3,Хлебобулочные изделия,bakery +4,Напитки,drinks +5,Молочные продукты,dairy +6,Безглютеновые продукты,gluten-free +7,Безлактозные продукты,lactose-free +8,Мясная продукция,meat +9,Птица,poultry diff --git a/backend/data/products.csv b/backend/data/products.csv new file mode 100644 index 0000000..517403c --- /dev/null +++ b/backend/data/products.csv @@ -0,0 +1,4 @@ +id,name,measure_unit,amount,description,image,producer,category,price +1,авокадо,гр,50,Спелое авокадо,avocado.jpg,TLC,2,50 +2,огурцы,гр,200,Огурцы гладкие,cucumbers.jpg,TLC,2,60 +3,Чай зеленый Молочный Улунг,гр,150,Зеленый чай,green_tea.jpg,TLC,4,300 \ No newline at end of file diff --git a/backend/data/users.csv b/backend/data/users.csv new file mode 100644 index 0000000..e3a6f5c --- /dev/null +++ b/backend/data/users.csv @@ -0,0 +1,7 @@ +id,username,email,password,first_name,last_name,address +2,vasya.pupkin,vasya@yandex.ru,Qwerty123poiu,Вася,Пупкин,Saint-Petersburg +3,july.kol,kolkinaa@mail.ru,mnbvcxz12345,Юля,Колкина,Saint-Petersburg +4,nastya.vasina,nastya@yandex.ru,1234Qwerty987,Настя,Васина,Saint-Petersburg +5,kisa.mura,kisa@yandex.ru,mnjggffdfdf,Кира,Муравьева,Saint-Petersburg +6,Kostya.Smirny,smirnov@yandex.ru,smirnuy098876,Константин,Смирнов,Saint-Petersburg +7,sonya.and,andr@mail.ru,andr0987,Соня,Андреева,Saint-Petersburg diff --git a/backend/products/management/commands/load_data.py b/backend/products/management/commands/load_data.py new file mode 100644 index 0000000..e2a9081 --- /dev/null +++ b/backend/products/management/commands/load_data.py @@ -0,0 +1,86 @@ +import csv +import os + +from django.conf import settings +from django.core.management.base import BaseCommand + +from products.models import Category, Product +from users.models import User + + +def read_users(): + with open(os.path.join(settings.BASE_DIR, 'data', 'users.csv'), + 'r', encoding='utf-8' + ) as f: + reader = csv.reader(f, delimiter=',') + for row in reader: + if row[0] == 'id': + continue + User.objects.get_or_create( + id=row[0], + username=row[1], + email=row[2], + password=row[3], + first_name=row[4], + last_name=row[5], + # role=row[6] + + ) + print('Данные из файла users.csv загружены') + + +def read_category(): + with open( + os.path.join( + settings.BASE_DIR, + 'data', 'category.csv', + ), + 'r', encoding='utf-8' + ) as f: + reader = csv.reader(f, delimiter=',') + for row in reader: + if row[0] == 'id': + continue + Category.objects.get_or_create( + id=row[0], + name=row[1], + slug=row[2], + ) + print('Данные из файла category.csv загружены') + + +def read_products(): + with open( + os.path.join( + settings.BASE_DIR, + 'data', 'products.csv', + ), + 'r', encoding='utf-8' + ) as f: + reader = csv.reader(f, delimiter=',') + for row in reader: + if row[0] == 'id': + continue + Product.objects.get_or_create( + id=row[0], + name=row[1], + measure_unit=row[2], + amount=row[3], + description=row[4], + image=row[5], + producer=row[6], + category=row[7], + price=row[8] + ) + print('Данные из файла products.csv загружены') + + +class Command(BaseCommand): + + def handle(self, *args, **options): + read_users() + read_category() + read_products() + + + From fa389464f3e54a25206f0384686d4bc6f3d1eb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 09:47:56 +0300 Subject: [PATCH 07/14] add urls --- backend/api/urls.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 backend/api/urls.py diff --git a/backend/api/urls.py b/backend/api/urls.py new file mode 100644 index 0000000..6b0df6e --- /dev/null +++ b/backend/api/urls.py @@ -0,0 +1,22 @@ +from django.urls import include, path +from rest_framework.routers import DefaultRouter + +from .views import ( + ShoppingCartViewSet +) + +app_name = 'api' + +router = DefaultRouter() + + + + +router.register( + r'shopping_cart', ShoppingCartViewSet, basename='shopping_carts') + + +urlpatterns = [ + path('', include(router.urls)), + +] From c302c1303d79b899cc9a3dbabbab7fd0cd916066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 10:05:22 +0300 Subject: [PATCH 08/14] add Shopping cart serializer --- backend/api/serializers.py | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 backend/api/serializers.py diff --git a/backend/api/serializers.py b/backend/api/serializers.py new file mode 100644 index 0000000..57cc06e --- /dev/null +++ b/backend/api/serializers.py @@ -0,0 +1,53 @@ +from django.db import transaction +from djoser.serializers import UserCreateSerializer +from rest_framework import serializers + +from products.models import Product, Favorite, Category +from users.models import User + +from orders.models import Order, ShoppingCart + + + +class ShoppingCartListSerializer(serializers.ModelSerializer): + """Serializer for product representation.""" + product_name = serializers.SerializerMethodField() + product_amount = serializers.SerializerMethodField() + product_price = serializers.SerializerMethodField() + + class Meta: + model = ShoppingCart + fields = ('product_name', + 'product_amount', 'product_price') + + def get_product_name(self, obj): + return obj.product.name + + def get_product_amount(self, obj): + return obj.product.amount + + def get_product_price(self, obj): + return obj.product.price + + +class ShoppingCartPostUpdateSerializer(serializers.ModelSerializer): + count_of_product = serializers.IntegerField(default=1) + + class Meta: + fields = '__all__' + model = ShoppingCart + validators = ( + serializers.UniqueTogetherValidator( + queryset=ShoppingCart.objects.all(), + fields=('user', 'product'), + message='Вы уже добавили этот продукт в корзину!' + ), + ) + + def validate_count_of_product(self, data): + if data < 1: + raise serializers.ValidationError( + 'Количество товара в корзине должно быть не меньше 1!') + return data + + From 205b2d8a3c624a238afd80c84649b9c1ca217802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 13:16:13 +0300 Subject: [PATCH 09/14] add Shopping cart Order model --- backend/orders/models.py | 58 +++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/backend/orders/models.py b/backend/orders/models.py index 3d029b6..2cdcd00 100644 --- a/backend/orders/models.py +++ b/backend/orders/models.py @@ -4,23 +4,15 @@ from users.models import User from products.models import Product -SHOPPINGCART = (('Ordered', 'Передано в заказ'), ('In work','В работе')) - -STATUS = (('Ordered', 'Оформлен'), ('In processing', 'В обработке'), - ('Completed', 'Комплектуется'), - ('Gathered', 'Собран'),('In delivering', 'Передан в доставку'), - ('Delivered', 'Доставлен'), ('Completed', 'Завершен')) - -PAYMENT_METHODS = (('Cash', 'Наличные'), - ('By card on the website', 'Картой на сайте'), - ('In getting','При получении')) - -DELIVERY_METHOD = (('Point of delivery', 'Пункт выдачи'), - ('By courier', 'Курьером')) - class ShoppingCart(models.Model): """Model for creating a shopping cart.""" + + SHOPPINGCART = ( + ('Ordered', 'Передано в заказ'), + ('In work', 'В работе') + ) + user = models.ForeignKey( User, on_delete=models.CASCADE, @@ -50,15 +42,43 @@ class Meta: verbose_name = 'Корзина' verbose_name_plural = 'Корзина' constraints = [ - models.UniqueConstraint( - fields=['user', 'product'], - name='unique_shopping_cart' - ) + models.UniqueConstraint( + fields=['user', 'product'], + name='unique_shopping_cart' + ) ] class Order(models.Model): """Model for creating an order.""" + + STATUS = ( + ('Ordered', 'Оформлен'), + ('In processing', 'В обработке'), + ('Completed', 'Комплектуется'), + ('Gathered', 'Собран'), + ('In delivering', 'Передан в доставку'), + ('Delivered', 'Доставлен'), + ('Completed', 'Завершен') + ) + + PAYMENT_METHODS = ( + ('Cash', 'Наличные'), + ('By card on the website', 'Картой на сайте'), + ('In getting', 'При получении') + ) + + DELIVERY_METHOD = ( + ('Point of delivery', 'Пункт выдачи'), + ('By courier', 'Курьером') + ) + + customer = models.ForeignKey( + User, + on_delete=models.CASCADE, + related_name='orders', + verbose_name='Покупатель' + ) goods = models.ForeignKey( ShoppingCart, on_delete=models.CASCADE, @@ -73,7 +93,7 @@ class Order(models.Model): max_length=50, choices=STATUS, default='Оформлен' - ) + ) payment_method = models.CharField( max_length=50, choices=PAYMENT_METHODS, From 84ce3a0689285fa4f965976dc974e6f6674b1698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 14:48:55 +0300 Subject: [PATCH 10/14] add Order model --- backend/orders/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/orders/models.py b/backend/orders/models.py index 2cdcd00..f6cde69 100644 --- a/backend/orders/models.py +++ b/backend/orders/models.py @@ -73,7 +73,7 @@ class Order(models.Model): ('By courier', 'Курьером') ) - customer = models.ForeignKey( + user = models.ForeignKey( User, on_delete=models.CASCADE, related_name='orders', From 8ca234f5ed39fbf9aaa0c7e87542a534c97f14a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 15:42:29 +0300 Subject: [PATCH 11/14] fix flake8 --- backend/api/serializers.py | 14 +---- backend/api/urls.py | 22 -------- backend/orders/admin.py | 5 +- backend/orders/models.py | 52 ++++++++----------- .../products/management/commands/load_data.py | 6 +-- 5 files changed, 26 insertions(+), 73 deletions(-) diff --git a/backend/api/serializers.py b/backend/api/serializers.py index 57cc06e..7e86463 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -1,13 +1,6 @@ -from django.db import transaction -from djoser.serializers import UserCreateSerializer +from orders.models import ShoppingCart from rest_framework import serializers -from products.models import Product, Favorite, Category -from users.models import User - -from orders.models import Order, ShoppingCart - - class ShoppingCartListSerializer(serializers.ModelSerializer): """Serializer for product representation.""" @@ -17,8 +10,7 @@ class ShoppingCartListSerializer(serializers.ModelSerializer): class Meta: model = ShoppingCart - fields = ('product_name', - 'product_amount', 'product_price') + fields = ('product_name', 'product_amount', 'product_price') def get_product_name(self, obj): return obj.product.name @@ -49,5 +41,3 @@ def validate_count_of_product(self, data): raise serializers.ValidationError( 'Количество товара в корзине должно быть не меньше 1!') return data - - diff --git a/backend/api/urls.py b/backend/api/urls.py index 6b0df6e..e69de29 100644 --- a/backend/api/urls.py +++ b/backend/api/urls.py @@ -1,22 +0,0 @@ -from django.urls import include, path -from rest_framework.routers import DefaultRouter - -from .views import ( - ShoppingCartViewSet -) - -app_name = 'api' - -router = DefaultRouter() - - - - -router.register( - r'shopping_cart', ShoppingCartViewSet, basename='shopping_carts') - - -urlpatterns = [ - path('', include(router.urls)), - -] diff --git a/backend/orders/admin.py b/backend/orders/admin.py index 61a13a3..2a565c3 100644 --- a/backend/orders/admin.py +++ b/backend/orders/admin.py @@ -1,6 +1,5 @@ from django.contrib import admin - -from orders.models import ShoppingCart, Order +from orders.models import ShoppingCart @admin.register(ShoppingCart) @@ -8,5 +7,3 @@ class ShoppingCartAdmin(admin.ModelAdmin): list_display = ('id', 'user', 'product', 'quantity', 'status') list_editable = ('user', 'product', 'quantity') search_fields = ('user',) - - diff --git a/backend/orders/models.py b/backend/orders/models.py index f6cde69..dfc8ee8 100644 --- a/backend/orders/models.py +++ b/backend/orders/models.py @@ -1,17 +1,15 @@ -from django.core.validators import MinValueValidator, MaxValueValidator from django.db import models +from django.core.validators import MinValueValidator, MaxValueValidator -from users.models import User from products.models import Product +from users.models import User class ShoppingCart(models.Model): """Model for creating a shopping cart.""" - SHOPPINGCART = ( - ('Ordered', 'Передано в заказ'), - ('In work', 'В работе') - ) + SHOPPINGCART = (('Ordered', 'Передано в заказ'), + ('In work', 'В работе')) user = models.ForeignKey( User, @@ -28,8 +26,8 @@ class ShoppingCart(models.Model): quantity = models.IntegerField( verbose_name='Количество товара', validators=[ - MinValueValidator(1, 'Разрешены значения от 1 до 100'), - MaxValueValidator(10000, 'Разрешены значения от 1 до 100') + MinValueValidator(1, 'Разрешены значения от 1 до 100'), + MaxValueValidator(10000, 'Разрешены значения от 1 до 100') ] ) status = models.CharField( @@ -42,36 +40,30 @@ class Meta: verbose_name = 'Корзина' verbose_name_plural = 'Корзина' constraints = [ - models.UniqueConstraint( - fields=['user', 'product'], - name='unique_shopping_cart' - ) + models.UniqueConstraint( + fields=['user', 'product'], + name='unique_shopping_cart' + ) ] class Order(models.Model): """Model for creating an order.""" - STATUS = ( - ('Ordered', 'Оформлен'), - ('In processing', 'В обработке'), - ('Completed', 'Комплектуется'), - ('Gathered', 'Собран'), - ('In delivering', 'Передан в доставку'), - ('Delivered', 'Доставлен'), - ('Completed', 'Завершен') - ) + STATUS = (('Ordered', 'Оформлен'), + ('In processing', 'В обработке'), + ('Completed', 'Комплектуется'), + ('Gathered', 'Собран'), + ('In delivering', 'Передан в доставку'), + ('Delivered', 'Доставлен'), + ('Completed', 'Завершен')) - PAYMENT_METHODS = ( - ('Cash', 'Наличные'), - ('By card on the website', 'Картой на сайте'), - ('In getting', 'При получении') - ) + PAYMENT_METHODS = (('Cash', 'Наличные'), + ('By card on the website', 'Картой на сайте'), + ('In getting', 'При получении')) - DELIVERY_METHOD = ( - ('Point of delivery', 'Пункт выдачи'), - ('By courier', 'Курьером') - ) + DELIVERY_METHOD = (('Point of delivery', 'Пункт выдачи'), + ('By courier', 'Курьером')) user = models.ForeignKey( User, diff --git a/backend/products/management/commands/load_data.py b/backend/products/management/commands/load_data.py index e2a9081..31bdb34 100644 --- a/backend/products/management/commands/load_data.py +++ b/backend/products/management/commands/load_data.py @@ -10,8 +10,7 @@ def read_users(): with open(os.path.join(settings.BASE_DIR, 'data', 'users.csv'), - 'r', encoding='utf-8' - ) as f: + 'r', encoding='utf-8') as f: reader = csv.reader(f, delimiter=',') for row in reader: if row[0] == 'id': @@ -81,6 +80,3 @@ def handle(self, *args, **options): read_users() read_category() read_products() - - - From 0c439e7bd661d201e5457b4e0d87e4acaf1397c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 15:46:10 +0300 Subject: [PATCH 12/14] fix flake8 --- backend/orders/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/orders/models.py b/backend/orders/models.py index dfc8ee8..a05d7d8 100644 --- a/backend/orders/models.py +++ b/backend/orders/models.py @@ -1,5 +1,5 @@ +from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models -from django.core.validators import MinValueValidator, MaxValueValidator from products.models import Product from users.models import User From cfd5bb5f52522439cee7313bf84f41fa5740cfaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 16:27:46 +0300 Subject: [PATCH 13/14] fix flake8 --- backend/orders/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/orders/models.py b/backend/orders/models.py index a05d7d8..911e346 100644 --- a/backend/orders/models.py +++ b/backend/orders/models.py @@ -104,6 +104,7 @@ class Order(models.Model): total_price = models.IntegerField( default=0 ) + permission_personal_data = models.BooleanField(default=False) class Meta: ordering = ['-date'] From f3685883a20e968189f066f381777bb3f15d1c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D0=BB=D0=B8=D0=B0=D0=BD=D0=B0=20=D0=A1=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= Date: Thu, 19 Oct 2023 16:44:24 +0300 Subject: [PATCH 14/14] fix flake8 --- backend/orders/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/orders/models.py b/backend/orders/models.py index 911e346..a05d7d8 100644 --- a/backend/orders/models.py +++ b/backend/orders/models.py @@ -104,7 +104,6 @@ class Order(models.Model): total_price = models.IntegerField( default=0 ) - permission_personal_data = models.BooleanField(default=False) class Meta: ordering = ['-date']