Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
armanddidierjean committed Oct 20, 2023
1 parent d71c488 commit b06f58b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/endpoints/todos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async def get_todos(
return await cruds_todos.get_items_by_user_id(db=db, user_id=user.id)


# We define a new endpoint, accepting a POST, that intend to create a new todo
@router.post(
"/todos/",
response_model=schemas_todos.TodosItemBase,
Expand All @@ -53,7 +54,7 @@ async def create_todo(
id=todo_id,
creation=creation_time,
user_id=user.id,
**item.dict(), # We add all informations contained in the schema
**item.dict(), # We add all informations contained in the schema, the operation is called unpacking
)
try:
res = await cruds_todos.create_item(
Expand All @@ -62,9 +63,11 @@ async def create_todo(
)
return res
except ValueError as error:

Check warning on line 65 in app/endpoints/todos.py

View check run for this annotation

Codecov / codecov/patch

app/endpoints/todos.py#L64-L65

Added lines #L64 - L65 were not covered by tests
# If we failed to create the object in the database, we send back a 400 error code with the detail of the error
raise HTTPException(status_code=400, detail=str(error))

Check warning on line 67 in app/endpoints/todos.py

View check run for this annotation

Codecov / codecov/patch

app/endpoints/todos.py#L67

Added line #L67 was not covered by tests


# We define a POST endpoint to make a todo as done or undone
@router.post(
"/todos/{id}/check",
status_code=204,
Expand Down
2 changes: 1 addition & 1 deletion app/models/models_todos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class TodosItem(Base):
)
name: Mapped[str] = mapped_column(String, nullable=False)
creation: Mapped[date] = mapped_column(Date, nullable=False)
deadline: Mapped[date | None] = mapped_column(Date)
deadline: Mapped[date | None] = mapped_column(Date, nullable=True)
done: Mapped[bool] = mapped_column(Boolean, nullable=False)

0 comments on commit b06f58b

Please sign in to comment.