-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from healthy-food-and-dietary-products/feature…
…/orders_api Feature/orders api
- Loading branch information
Showing
12 changed files
with
368 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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,13 @@ | ||
from rest_framework import permissions | ||
|
||
|
||
class IsAuthorOnly(permissions.BasePermission): | ||
"""Only Author has permissions.""" | ||
|
||
def has_permission(self, request, view): | ||
return ( | ||
request.method in permissions.SAFE_METHODS and request.user.is_authenticated | ||
) | ||
|
||
def has_object_permission(self, request, view, obj): | ||
return obj.user == request.user |
This file contains 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 |
---|---|---|
|
@@ -8,3 +8,4 @@ id,name,slug | |
7,Безлактозные продукты,lactose-free | ||
8,Мясная продукция,meat | ||
9,Птица,poultry | ||
10,Орехи,nuts |
This file contains 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,22 @@ | ||
id,name | ||
1,Авокадо | ||
2,Яблоко | ||
3,Пшеничная Мука высший сорт | ||
4,Ржаная Мука | ||
5,Дрожжи хлебопекарные | ||
6,Яйца | ||
7,Яичный порошок | ||
8,Огурцы | ||
9,Соль | ||
10,Зеленый чай | ||
11,Черный чай | ||
12,Молоко | ||
13,Творог | ||
14,Сливочное Масло | ||
15,Оливковое масло | ||
16,Зерновые хлопья | ||
17,Мюсли | ||
18,Бананы | ||
19,Груши | ||
20,Сливы, | ||
21,Сахар |
This file contains 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,5 @@ | ||
id,name,producer_type,description,address | ||
1,Курочкин П. Н.,Индивидуальный предприниматель,Торговля молочными продуктами,Москва | ||
2,Веселый молочник,Юридическое лицо,Торговля молочными продуктами,Тверь | ||
3,Выборжец,Юридическое лицо,Фрукты и овощи круглый год,Ленинградская область | ||
4,Хлебный дом,Юридическое лицо,Хлебобулочные изделия и выпечка,Санкт-Петербург |
This file contains 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,9 @@ | ||
id,parent_category_id,name,slug | ||
1,3,Ржаной хлеб,rye_bread | ||
2,3,Хлебцы зерновые,grain_loaves | ||
3,4,Чай черный,black_tea | ||
4,4,Чай зеленый,green_tea | ||
5,6,Хлебцы безглютеновые,gluten-free_loaves | ||
6,6,Печенье безглютеновое,gluten-free_cookies | ||
7,7,Молоко без лактозы,lactose-free_milk | ||
8,2,Зеленые овощи,fruts |
This file contains 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,6 @@ | ||
id,name,slug | ||
1,Детям,kids | ||
2,Диабет,diabetes | ||
3,Мало калорий,min_calories | ||
4,Сытно,hearty | ||
5,Витамины,vitamins |
This file contains 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,7 +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 | ||
id,username,email,password,first_name,last_name,city,address | ||
2,vasya.pupkin,vasya@yandex.ru,Qwerty123poiu,Вася,Пупкин,Saint-Petersburg,ул.Брянцева д.4 кв18 | ||
3,july.kol,kolkinaa@mail.ru,mnbvcxz12345,Юля,Колкина,Saint-Petersburg,канал Грибоедова д.6 кв 11 | ||
4,nastya.vasina,nastya@yandex.ru,1234Qwerty987,Настя,Васина,Saint-Petersburg,Московский проспект д. 5 кв 98 | ||
5,kisa.mura,kisa@yandex.ru,mnjggffdfdf,Кира,Муравьева,Saint-Petersburg,Василеостровская д.7 кв 3 | ||
6,Kostya.Smirny,smirnov@yandex.ru,smirnuy098876,Константин,Смирнов,Saint-Petersburg | ||
7,sonya.and,andr@mail.ru,andr0987,Соня,Андреева,Saint-Petersburg |
This file contains 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,33 +1,46 @@ | ||
from django.contrib import admin | ||
|
||
from orders.models import Order, ShoppingCart | ||
from orders.models import Order, ShoppingCart, ShoppingCartProduct | ||
|
||
|
||
class ShoppingCartProductInline(admin.TabularInline): | ||
model = ShoppingCartProduct | ||
list_display = ("id", "product", "quantity") | ||
list_editable = ("product", "quantity") | ||
|
||
|
||
@admin.register(ShoppingCart) | ||
class ShoppingCartAdmin(admin.ModelAdmin): | ||
list_display = ("id", "user", "product", "quantity", "status") | ||
list_editable = ("user", "product", "quantity") | ||
search_fields = ("user",) | ||
inlines = (ShoppingCartProductInline,) | ||
list_display = ( | ||
"id", | ||
"user", | ||
"status", | ||
) | ||
list_editable = ("status",) | ||
list_filter = ("user", "status") | ||
|
||
|
||
@admin.register(Order) | ||
class OrderAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"id", | ||
"user", | ||
"goods", | ||
"date", | ||
"order_number", | ||
"shopping_cart", | ||
"ordering_date", | ||
"status", | ||
"payment_method", | ||
"is_paid", | ||
"delivery_method", | ||
"comment", | ||
"total_price", | ||
"address", | ||
"package", | ||
) | ||
list_editable = ( | ||
"status", | ||
"payment_method", | ||
"is_paid", | ||
"comment", | ||
"delivery_method", | ||
"address", | ||
"package", | ||
) | ||
list_filter = ("ordering_date", "order_number") |
This file contains 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 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,25 @@ | ||
# Generated by Django 4.2.6 on 2023-10-23 09:41 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0001_initial"), | ||
("orders", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="order", | ||
name="address", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="users.address", | ||
verbose_name="Адрес покупателя", | ||
), | ||
), | ||
] |
Oops, something went wrong.