sync: migrate secure-online-shop to Gitea (2026-08-10)

This commit is contained in:
konturai-ops
2026-08-10 15:26:59 +00:00
commit 2022c8890d
44 changed files with 3196 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Annotated
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, StringConstraints
NameField = Annotated[
StrictStr,
StringConstraints(strip_whitespace=True, min_length=3, max_length=120),
]
DescriptionField = Annotated[
StrictStr,
StringConstraints(strip_whitespace=True, min_length=1, max_length=1000),
]
class ProductCreate(BaseModel):
model_config = ConfigDict(extra="forbid")
name: NameField
description: DescriptionField | None = None
price: Annotated[Decimal, Field(gt=0, max_digits=10, decimal_places=2)]
stock: Annotated[StrictInt, Field(ge=0, le=1_000_000)]
is_active: StrictBool = True
class ProductResponse(BaseModel):
model_config = ConfigDict(from_attributes=True, extra="forbid")
id: int
name: str
description: str | None
price: Decimal
stock: int
is_active: bool
created_at: datetime