Fixed formatting and type definitions
This commit is contained in:
parent
bbe0df9546
commit
d97335e0c7
5 changed files with 112 additions and 65 deletions
|
|
@ -1,23 +1,32 @@
|
|||
from app.database import (
|
||||
add_to_database,
|
||||
get_from_database,
|
||||
get_from_database_where,
|
||||
get_from_database_where_id,
|
||||
)
|
||||
from app.models.project import Project
|
||||
from app.database import add_to_database, get_from_database, get_from_database_where, get_from_database_where_id
|
||||
|
||||
# For now, this is a manifest for the project model architecture:
|
||||
# For now, this is a manifest for the project model architecture:
|
||||
|
||||
# A project consists of:
|
||||
# ID (Autoincrement num, required),
|
||||
# A project consists of:
|
||||
# ID (Autoincrement num, required),
|
||||
# Parent (Num, optional, if this field contains a number (not none or 0), it is considered a child project of project with ID = num)
|
||||
# Title (Required, text),
|
||||
# Title (Required, text),
|
||||
# Content (Optional, for now is string text but needs to store full Markdown including images in the future)
|
||||
|
||||
|
||||
def get_all():
|
||||
return {"projects": get_from_database(Project)}
|
||||
return get_from_database(Project)
|
||||
|
||||
def get_by_id(project_id):
|
||||
return {"project": get_from_database_where_id(Project, project_id)[0]}
|
||||
|
||||
def get_with_parent(project_id):
|
||||
return {"projects": get_from_database_where(Project, Project.parent_id, project_id)}
|
||||
def get_by_id(project_id: int):
|
||||
return get_from_database_where_id(Project, project_id)
|
||||
|
||||
|
||||
def get_with_parent(project_id: int):
|
||||
return get_from_database_where(Project, Project.parent_id, project_id)
|
||||
|
||||
|
||||
def create(project: Project):
|
||||
add_to_database(project)
|
||||
return project
|
||||
return project
|
||||
|
|
|
|||
Loading…
Reference in a new issue