Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Post(BaseModel):
id: int = Field(default_factory=next_post_id)
created_at: datetime = Field(default_factory=datetime.now)
updated_at: datetime = Field(default_factory=datetime.now)
title_of_post: str = Field(..., max_length=100)
body: str
author: str

Expand Down
4 changes: 4 additions & 0 deletions posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class PostCreateSchema(BaseModel):
body: str
author: str
title: str


router = APIRouter()
Expand All @@ -29,5 +30,8 @@ def get_by_id(post_id: int):

@router.post("/posts")
def create_new_post(post_create: PostCreateSchema):
if len(post.title) > 100:
return "Post title should be max. 100 cahracters long"

post = Post(**post_create.dict())
return save_post(post)
3 changes: 0 additions & 3 deletions ticket-MT-846.txt

This file was deleted.