You've already forked Promocode-API
mirror of
https://github.com/devitq/Promocode-API.git
synced 2026-05-23 20:17:12 +00:00
feat: added comments cruds
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import datetime
|
||||
import uuid
|
||||
from typing import ClassVar
|
||||
|
||||
from ninja import ModelSchema, Schema
|
||||
from pydantic import Field, StrictInt
|
||||
|
||||
from apps.promo.models import PromocodeComment
|
||||
from apps.user.models import User
|
||||
|
||||
|
||||
@@ -96,3 +98,35 @@ class PromocodeLikeOut(Schema):
|
||||
|
||||
class PromocodeRemoveLikeOut(Schema):
|
||||
status: str = "ok"
|
||||
|
||||
|
||||
class PromocodeCommentsFilters(Schema):
|
||||
limit: int = Field(10, gt=0, description="Limit must be greater than 0")
|
||||
offset: int = Field(
|
||||
0, ge=0, description="Offset must be greater than or equal to 0"
|
||||
)
|
||||
|
||||
|
||||
class CommentIn(ModelSchema):
|
||||
class Meta:
|
||||
model = PromocodeComment
|
||||
fields: ClassVar[list[str]] = [
|
||||
PromocodeComment.text.field.name
|
||||
]
|
||||
|
||||
|
||||
class CommentAuthor(Schema):
|
||||
name: str
|
||||
surname: str
|
||||
avatar_url: str | None
|
||||
|
||||
|
||||
class CommentOut(Schema):
|
||||
id: uuid.UUID
|
||||
text: str
|
||||
date: datetime.datetime
|
||||
author: CommentAuthor
|
||||
|
||||
|
||||
class CommentDeletedOut(Schema):
|
||||
status: str = "ok"
|
||||
|
||||
Reference in New Issue
Block a user