Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
task_treker
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
Мырзабеков Бекайдар
task_treker
Commits
9cdc64ec
Commit
9cdc64ec
authored
Nov 24, 2023
by
Мырзабеков Бекайдар
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed create and update tasks
parent
e5691170
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
schemas.py
src/app/api/task/schemas.py
+3
-1
services.py
src/app/api/task/services.py
+24
-8
No files found.
src/app/api/task/schemas.py
View file @
9cdc64ec
...
...
@@ -21,12 +21,14 @@ class TaskListSchema(TaskBaseSchema, TaskIdSchema):
class
TaskPostSchema
(
TaskBaseSchema
):
description
:
str
status
:
UUID
|
None
=
None
category
:
UUID
|
None
=
None
types
:
List
[
UUID
]
|
None
=
None
class
TaskPatchSchema
(
TaskBaseSchema
):
description
:
str
|
None
=
None
status
:
UUID
|
None
status
:
UUID
|
None
=
None
category
:
UUID
|
None
=
None
types
:
List
[
UUID
]
|
None
=
None
...
...
src/app/api/task/services.py
View file @
9cdc64ec
...
...
@@ -2,7 +2,7 @@ from uuid import UUID
from
db.repositories
import
(
TaskRepository
,
StatusRepository
,
CommentRepository
,
UserRepository
UserRepository
,
CategoryRepository
)
from
exceptions
import
common
as
common_exc
,
http
as
http_exc
from
db.models
import
Type
,
Status
...
...
@@ -14,6 +14,7 @@ class TaskService:
status_repository
=
StatusRepository
()
comment_repository
=
CommentRepository
()
user_repository
=
UserRepository
()
category_repository
=
CategoryRepository
()
async
def
get_task_list
(
self
,
**
kwargs
):
tasks
=
await
self
.
task_repository
.
get_list
(
**
kwargs
)
...
...
@@ -21,9 +22,10 @@ class TaskService:
async
def
get_task
(
self
,
id
:
UUID
):
task
=
await
self
.
task_repository
.
get
(
id
=
id
)
await
task
.
fetch_related
(
'status'
,
'types'
)
await
task
.
fetch_related
(
'status'
,
'
category'
,
'
types'
)
status_id
=
task
.
status
.
id
if
task
.
status
else
None
category_id
=
task
.
category
.
id
if
task
.
category
else
None
types_data
=
[
type
.
id
for
type
in
task
.
types
]
task_data
=
{
...
...
@@ -31,6 +33,7 @@ class TaskService:
"title"
:
task
.
title
,
"description"
:
task
.
description
,
"status"
:
status_id
,
"category"
:
category_id
,
"types"
:
types_data
}
...
...
@@ -38,20 +41,24 @@ class TaskService:
async
def
create_task
(
self
,
**
kwargs
):
status_uuid
=
kwargs
.
get
(
'status'
)
category_uuid
=
kwargs
.
get
(
'category'
)
type_uuids
=
kwargs
.
get
(
'types'
,
[])
if
status_uuid
is
None
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
"Validation error: status: Value must not be None"
)
if
status_uuid
is
None
or
category_uuid
is
None
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
"Validation error: Value must not be None"
)
try
:
status
=
await
self
.
status_repository
.
get
(
status_uuid
)
category
=
await
self
.
category_repository
.
get
(
category_uuid
)
except
common_exc
.
NotFoundException
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
f
"status does not exist"
)
except
common_exc
.
NotFoundException
as
e
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
str
(
e
)
)
task
=
await
self
.
task_repository
.
create
(
title
=
kwargs
.
get
(
'title'
),
description
=
kwargs
.
get
(
'description'
),
status
=
status
status
=
status
,
category
=
category
)
types
=
await
Type
.
filter
(
id__in
=
type_uuids
)
...
...
@@ -61,10 +68,19 @@ class TaskService:
async
def
update_task
(
self
,
id
:
UUID
,
**
kwargs
):
status_uuid
=
kwargs
.
get
(
'status'
)
category_uuid
=
kwargs
.
get
(
'category'
)
type_uuids
=
kwargs
.
get
(
'types'
,
[])
if
status_uuid
:
kwargs
[
'status'
]
=
await
self
.
status_repository
.
get
(
status_uuid
)
try
:
kwargs
[
'status'
]
=
await
self
.
status_repository
.
get
(
status_uuid
)
except
common_exc
.
NotFoundException
as
e
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
str
(
e
))
if
category_uuid
:
try
:
kwargs
[
'category'
]
=
await
self
.
category_repository
.
get
(
category_uuid
)
except
common_exc
.
NotFoundException
as
e
:
raise
http_exc
.
HTTPBadRequestException
(
detail
=
str
(
e
))
types
=
kwargs
.
pop
(
'types'
,
[])
...
...
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