Added update project route and logic
This commit is contained in:
parent
f5b274a678
commit
4fc1f58f30
3 changed files with 52 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ from app.database import (
|
|||
get_from_database,
|
||||
get_from_database_where,
|
||||
get_from_database_where_id,
|
||||
update_database_where,
|
||||
)
|
||||
from app.models.project import Project
|
||||
|
||||
|
|
@ -17,7 +18,11 @@ def get_by_id(project_id: int):
|
|||
|
||||
|
||||
def get_with_parent(project_id: int):
|
||||
return get_from_database_where(Project, Project.parent_id, project_id)
|
||||
return get_from_database_where(
|
||||
Project,
|
||||
Project.parent_id,
|
||||
project_id,
|
||||
)
|
||||
|
||||
|
||||
def create(project: Project):
|
||||
|
|
@ -25,5 +30,23 @@ def create(project: Project):
|
|||
return project
|
||||
|
||||
|
||||
def update(
|
||||
project_id: int,
|
||||
update_attribute: str,
|
||||
new_value: int | str | None,
|
||||
):
|
||||
return update_database_where(
|
||||
Project,
|
||||
Project.id,
|
||||
project_id,
|
||||
update_attribute,
|
||||
new_value,
|
||||
)
|
||||
|
||||
|
||||
def delete(project_id: int):
|
||||
return delete_from_database_where(Project, Project.id, project_id)
|
||||
return delete_from_database_where(
|
||||
Project,
|
||||
Project.id,
|
||||
project_id,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue