feat: added comments cruds

This commit is contained in:
ITQ
2025-01-25 22:01:36 +03:00
parent 974bb1acb4
commit 69fa312201
3 changed files with 208 additions and 2 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
from api.v1.user import schemas
from apps.promo.models import Promocode
from apps.promo.models import Promocode, PromocodeComment
from apps.user.models import User
@@ -29,3 +29,16 @@ def map_promocode_to_schema(promocode: Promocode) -> schemas.PromocodeViewOut:
comment_count=promocode.comment_count,
active=promocode.active,
)
def map_comment_to_schema(comment: PromocodeComment) -> schemas.CommentOut:
return schemas.CommentOut(
id=comment.id,
text=comment.text,
date=comment.date,
author=schemas.CommentAuthor(
name=comment.author.name,
surname=comment.author.surname,
avatar_url=comment.author.avatar_url
)
)