feat: add comments feature with nested replies and recursive rendering
All checks were successful
ci/woodpecker/pr/pipeline Pipeline was successful
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.
This commit is contained in:
55
app/application/dtos/comment.py
Normal file
55
app/application/dtos/comment.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""DTOs for comment use cases.
|
||||
|
||||
This module defines Data Transfer Objects used for communication between
|
||||
application layer comment use cases and presentation layer.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CreateCommentDTO:
|
||||
"""DTO for creating a comment.
|
||||
|
||||
Carries comment creation data from API to use case.
|
||||
|
||||
Attributes:
|
||||
post_id: UUID of the post to comment on.
|
||||
author_id: Identifier of the comment author.
|
||||
content: Comment content string (Markdown supported).
|
||||
parent_id: Optional UUID of parent comment for replies.
|
||||
"""
|
||||
|
||||
post_id: UUID
|
||||
author_id: str
|
||||
content: str
|
||||
parent_id: UUID | None = None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CommentResponseDTO:
|
||||
"""DTO for comment response.
|
||||
|
||||
Carries complete comment data for API responses.
|
||||
|
||||
Attributes:
|
||||
id: Unique comment identifier.
|
||||
post_id: UUID of the parent post.
|
||||
author_id: Comment author identifier.
|
||||
content: Comment content string.
|
||||
parent_id: Optional UUID of parent comment.
|
||||
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
|
||||
Reference in New Issue
Block a user