Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
exflikt committed Oct 5, 2024
1 parent 080087b commit 6ae6285
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
29 changes: 5 additions & 24 deletions app/routers/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ async def get_order_session_to_confirm(request: Request, session_id: int):
error_status = None
return HTMLResponse(
templates.components.order_confirm(
request,
session_id,
order_session,
error_status,
request, session_id, order_session, error_status
)
)

Expand All @@ -79,11 +76,7 @@ async def place_order(request: Request, session_id: int):

return HTMLResponse(
templates.components.order_issued(
request,
session_id,
placement_id,
order_session,
error_status,
request, session_id, placement_id, order_session, error_status
)
)

Expand All @@ -101,11 +94,7 @@ async def add_order_item(

order_session.add(product)
return HTMLResponse(
templates.components.order_session(
request,
session_id,
order_session,
)
templates.components.order_session(request, session_id, order_session)
)


Expand All @@ -116,11 +105,7 @@ async def delete_order_item(request: Request, session_id: int, index: UUID):

order_session.delete(index)
return HTMLResponse(
templates.components.order_session(
request,
session_id,
order_session,
)
templates.components.order_session(request, session_id, order_session)
)


Expand All @@ -134,11 +119,7 @@ async def clear_order_items(

order_session.clear()
return HTMLResponse(
templates.components.order_session(
request,
session_id,
order_session,
)
templates.components.order_session(request, session_id, order_session)
)


Expand Down
15 changes: 7 additions & 8 deletions app/store/product.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Annotated
from uuid import UUID, uuid4

from databases import Database
import sqlmodel

from uuid import UUID, uuid4
from databases import Database


class Product(sqlmodel.SQLModel, table=True):
Expand Down Expand Up @@ -31,8 +30,8 @@ class OrderSession:
def __init__(self):
self.products: dict[UUID, Product] = {}
self.counted_products: dict[int, OrderSession.CountedProduct] = {}
self.total_count: int = 0
self.total_price: int = 0
self.total_count: int = 1
self.total_price: int = 1

def clear(self):
self.total_count = 0
Expand Down Expand Up @@ -64,9 +63,9 @@ def delete(self, id: UUID):

class CountedProduct:
def __init__(self, name: str, price: int):
self.name = name
self.price = Product.to_price_str(price)
self.count = 1
self.name: str = name
self.price: str = Product.to_price_str(price)
self.count: int = 1


class Table:
Expand Down

0 comments on commit 6ae6285

Please sign in to comment.