-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
93 additions
and
8 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,7 @@ | ||
@baseUrl=http://127.0.0.1:8000/api/v1 | ||
|
||
### | ||
GET {{baseUrl}}/recipes HTTP/1.1 | ||
|
||
### | ||
GET {{baseUrl}}/recipes/76 HTTP/1.1 |
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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,7 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ApiConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "api" | ||
verbose_name = "REST API" |
Empty file.
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,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
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 @@ | ||
from rest_framework import pagination | ||
|
||
|
||
class CreatedAtPagination(pagination.CursorPagination): | ||
ordering = "-pk" |
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,20 @@ | ||
from rest_framework import serializers | ||
|
||
from recipes import models | ||
|
||
|
||
class RecipeSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = models.Recipe | ||
fields = ( | ||
"pk", | ||
"name", | ||
"crust", | ||
"description", | ||
"weight", | ||
"thumbnail", | ||
"category", | ||
"program", | ||
"created_at", | ||
"updated_at", | ||
) |
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,4 @@ | ||
REST_FRAMEWORK = { | ||
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.CursorPagination", | ||
"PAGE_SIZE": 25, | ||
} |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,10 @@ | ||
from django.urls import path | ||
from rest_framework import routers | ||
|
||
from api import views | ||
|
||
router = routers.SimpleRouter(trailing_slash=False) | ||
router.register("recipes", views.RecipesViewSet) | ||
|
||
|
||
urlpatterns = router.urls |
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,10 @@ | ||
from rest_framework import generics, viewsets | ||
from api import serializers | ||
|
||
from recipes import repositories | ||
|
||
|
||
# Create your views here. | ||
class RecipesViewSet(viewsets.ReadOnlyModelViewSet): | ||
queryset = repositories.RecipesRepository.select() | ||
serializer_class = serializers.RecipeSerializer |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DefaultConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'recipes' | ||
verbose_name = 'Книга рецептов' | ||
class RecipesConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "recipes" | ||
verbose_name = "Книга рецептов" |
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
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,9 +1,10 @@ | ||
Django==4.1.10 | ||
Pillow==9.4.0 | ||
azure-storage-blob==12.13.0 | ||
boto3==1.26.24 | ||
django-storages==1.12.3 | ||
Django==4.1.10 | ||
djangorestframework==3.14.0 | ||
mysqlclient==2.1.1 | ||
Pillow==9.4.0 | ||
python-dotenv==0.19.2 | ||
requests==2.31.0 | ||
whitenoise==6.0.0 |