Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fast-food
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Мырзабеков Бекайдар
fast-food
Commits
89a451b5
Commit
89a451b5
authored
1 year ago
by
Мырзабеков Бекайдар
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added completed order status
parent
4170c57c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
ctrl.py
src/app/api/order/ctrl.py
+7
-0
routes.py
src/app/api/order/routes.py
+6
-0
services.py
src/app/api/order/services.py
+16
-0
No files found.
src/app/api/order/ctrl.py
View file @
89a451b5
...
...
@@ -36,3 +36,10 @@ class OrderController(BaseController):
async
def
get_list
(
self
,
**
kwargs
):
return
await
self
.
order_service
.
get_order_list
(
**
kwargs
)
async
def
completed_order
(
self
,
id
:
UUID
):
try
:
return
await
self
.
order_service
.
completed_order
(
id
)
except
common_exc
.
UpdateException
as
e
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
str
(
e
))
This diff is collapsed.
Click to expand it.
src/app/api/order/routes.py
View file @
89a451b5
...
...
@@ -30,3 +30,9 @@ async def get_order_status(id: UUID):
@
router
.
get
(
''
)
async
def
get_orders
(
page
:
int
=
1
,
size
:
int
=
10
):
return
await
ctrl
.
get_list
(
page
=
page
,
size
=
size
)
@
router
.
put
(
'/completed'
)
async
def
accepted_order
(
body
:
OrderIdSchema
):
order
=
await
ctrl
.
completed_order
(
**
body
.
model_dump
(
exclude_none
=
True
))
return
OrderStatusSchema
.
model_validate
(
order
)
This diff is collapsed.
Click to expand it.
src/app/api/order/services.py
View file @
89a451b5
...
...
@@ -74,3 +74,19 @@ class OrderService:
)
for
order
in
orders
[
'result'
]
]
}
async
def
completed_order
(
self
,
id
:
UUID
):
try
:
order
=
await
self
.
order_repository
.
get
(
id
=
id
)
except
common_exc
.
NotFoundException
as
e
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
str
(
e
))
if
order
.
status
!=
Order
.
StatusEnum
.
CONFIRMED
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
'Order must be in CONFIRMED status to be completed'
)
order
.
status
=
Order
.
StatusEnum
.
COMPLETED
await
order
.
save
()
return
{
'id'
:
order
.
id
,
'status'
:
order
.
status
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment