Skip to content

Commit

Permalink
Make the 'created_at' field in shoppingcart products consistent with …
Browse files Browse the repository at this point in the history
…the datetime format of Django and our project
  • Loading branch information
earlinn committed Dec 29, 2023
1 parent 14c5244 commit 59e1876
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions backend/api/orders_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def destroy(self, *args, **kwargs):
)
shopping_cart.remove(product_id)
logger.info(MESSAGE_ON_DELETE)
# TODO: add details on fields types and responses after __iter__ method
# (as there are no serializer) to api docs (swagger) for shopping cart list
# and shopping cart post endpoints
return Response(
{
"products": shopping_cart.__iter__(),
Expand Down
5 changes: 2 additions & 3 deletions backend/orders/shopping_carts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from datetime import datetime, timezone

from django.conf import settings
from django.utils import timezone

from products.models import Product

Expand All @@ -27,7 +26,7 @@ def add(self, product, quantity):
"category": p.category.slug,
"quantity": quantity,
"final_price": p.final_price,
"created_at": int(datetime.now(timezone.utc).timestamp()),
"created_at": timezone.localtime().isoformat(),
"amount": p.amount,
"measure_unit": p.measure_unit,
}
Expand Down

0 comments on commit 59e1876

Please sign in to comment.