diff --git a/src/ugc/api/v1/serializers.py b/src/ugc/api/v1/serializers.py index 851e161..aa90fb8 100644 --- a/src/ugc/api/v1/serializers.py +++ b/src/ugc/api/v1/serializers.py @@ -42,3 +42,4 @@ class FilmReviewDetail(Schema): film_id = fields.UUID() title = fields.Str() review = fields.Str() + created_at = fields.DateTime() diff --git a/src/ugc/domain/reviews/factories.py b/src/ugc/domain/reviews/factories.py index 5a65be8..e5ef5e8 100644 --- a/src/ugc/domain/reviews/factories.py +++ b/src/ugc/domain/reviews/factories.py @@ -1,3 +1,5 @@ +import datetime + from ..factories import BaseModelFactory from .types import FilmReview @@ -10,5 +12,5 @@ class FilmReviewFactory(BaseModelFactory[FilmReview]): def create_new(self, **kwargs) -> FilmReview: return self.cls( user_id=kwargs["user_id"], film_id=kwargs["film_id"], - title=kwargs["title"], review=kwargs["review"], + title=kwargs["title"], review=kwargs["review"], created_at=datetime.datetime.now(), ) diff --git a/src/ugc/domain/reviews/types.py b/src/ugc/domain/reviews/types.py index 3b2737a..2be1c18 100644 --- a/src/ugc/domain/reviews/types.py +++ b/src/ugc/domain/reviews/types.py @@ -1,3 +1,4 @@ +import datetime from typing import Any from uuid import UUID @@ -11,6 +12,7 @@ class FilmReview(BaseModel): film_id: UUID title: str review: str + created_at: datetime.datetime id: bytes | str | None = None # noqa: VNE003 @@ -18,7 +20,7 @@ class FilmReview(BaseModel): def from_dict(cls, data: dict) -> "FilmReview": dct = { "user_id": data["user_id"], "film_id": data["film_id"], - "title": data["title"], "review": data["review"], + "title": data["title"], "review": data["review"], "created_at": data["created_at"], } if review_id := data.get("id"): dct["id"] = review_id @@ -27,7 +29,7 @@ def from_dict(cls, data: dict) -> "FilmReview": def to_dict(self) -> dict[str, Any]: dct = { "user_id": str(self.user_id), "film_id": str(self.film_id), - "title": self.title, "review": self.review, + "title": self.title, "review": self.review, "created_at": self.created_at, } if self.id: dct["id"] = str(self.id)