All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful
Implement full comments system: domain entities (Comment, CommentLike), value objects (CommentContent), use cases (CRUD, like toggle), SQLAlchemy repository, API v1 endpoints, web UI with comment form and nested replies, i18n translations (EN/RU/FR/DE), and E2E tests. Fix nested reply (reply-to-reply) not displaying — the flat reply_comments dict was only queried for top-level comment IDs, so deeply nested replies were saved to DB (incrementing comment count) but never rendered. Switch to a recursive Jinja2 macro that renders any nesting depth.
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
"""Pydantic schemas for comments.
|
|
|
|
This module defines Pydantic models for comment request/response
|
|
validation in the API layer.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class CommentCreateSchema(BaseModel):
|
|
"""Schema for creating a comment.
|
|
|
|
Attributes:
|
|
content: Comment text content (Markdown supported).
|
|
parent_id: Optional parent comment ID for replies.
|
|
"""
|
|
|
|
content: str = Field(..., min_length=1, max_length=5000, description="Comment content")
|
|
parent_id: UUID | None = Field(default=None, description="Parent comment ID for replies")
|
|
|
|
|
|
class CommentResponseSchema(BaseModel):
|
|
"""Schema for comment response.
|
|
|
|
Attributes:
|
|
id: Unique comment identifier.
|
|
post_id: UUID of the parent post.
|
|
author_id: Comment author identifier.
|
|
content: Comment content text.
|
|
parent_id: Optional parent comment ID.
|
|
like_count: Number of likes on this comment.
|
|
created_at: Creation timestamp.
|
|
updated_at: Last update timestamp.
|
|
"""
|
|
|
|
id: UUID
|
|
post_id: UUID
|
|
author_id: str
|
|
content: str
|
|
parent_id: UUID | None = None
|
|
like_count: int = 0
|
|
created_at: datetime | None = None
|
|
updated_at: datetime | None = None
|
|
|
|
|
|
class CommentLikeResponseSchema(BaseModel):
|
|
"""Schema for comment like response.
|
|
|
|
Attributes:
|
|
id: Comment identifier.
|
|
like_count: Updated like count.
|
|
"""
|
|
|
|
id: UUID
|
|
like_count: int
|