Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions answerking/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Django base settings for answerking project.
"""
import os

from pathlib import Path

from corsheaders.defaults import default_headers, default_methods

from answerking_app.utils.json404_middleware_config import json404_response

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

Expand Down Expand Up @@ -35,6 +37,7 @@
"answerking_app.apps.AnswerkingAppConfig",
"rest_framework",
"corsheaders",
"drf_problems",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -72,7 +75,8 @@
REST_FRAMEWORK = {
"DEFAULT_PARSER_CLASSES": [
"rest_framework.parsers.JSONParser",
]
],
"EXCEPTION_HANDLER": "drf_problems.exceptions.exception_handler",
}

# Database
Expand Down Expand Up @@ -107,6 +111,8 @@
},
]

# JSON404 middleware
JSON404_DATA_FUNCTION = json404_response
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

Expand Down
1 change: 1 addition & 0 deletions answerking/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
path("api/", include("answerking_app.urls.category_urls")),
path("api/", include("answerking_app.urls.order_urls")),
path("admin/", admin.site.urls),
path("", include("drf_problems.urls")),
]

if settings.DEBUG:
Expand Down
2 changes: 1 addition & 1 deletion answerking_app/models/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def create(self, validated_data: dict) -> Order:
)
for order_item in order_items_data:
item_data: ItemType = order_item.pop("item")
item: Item = get_object_or_404(Item, pk=item_data["id"])
item: Item = get_object_or_404(Item, pk=item_data["id"]) # type: ignore[reportTypedDictNotRequiredAccess]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ignoring type error here?

if item.retired:
continue
OrderLine.objects.create(order=order, item=item, **order_item)
Expand Down
Loading