Add frontend project structure with React/TypeScript setup
This commit is contained in:
1 parent
c7abb73c66
commit
6914a6855c
58 files changed
+9056
-236
No files matched your search
@@ -0,0 +1,19 @@
|
||||
"""
|
||||
Pydantic schemas for Newzy application.
|
||||
"""
|
||||
|
||||
from .article import ArticleCreate, ArticleResponse, ArticleUpdate
|
||||
from .author import AuthorCreate, AuthorResponse, AuthorUpdate
|
||||
from .category import CategoryCreate, CategoryResponse, CategoryUpdate
|
||||
|
||||
__all__ = [
|
||||
"ArticleCreate",
|
||||
"ArticleResponse",
|
||||
"ArticleUpdate",
|
||||
"AuthorCreate",
|
||||
"AuthorResponse",
|
||||
"AuthorUpdate",
|
||||
"CategoryCreate",
|
||||
"CategoryResponse",
|
||||
"CategoryUpdate",
|
||||
]
|
||||
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
Pydantic schemas for Article model.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ArticleBase(BaseModel):
|
||||
"""Base article schema."""
|
||||
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
content: str = Field(..., min_length=1)
|
||||
|
||||
|
||||
class ArticleCreate(ArticleBase):
|
||||
"""Schema for creating a new article."""
|
||||
|
||||
author_id: int = Field(..., ge=1)
|
||||
category_id: int = Field(..., ge=1)
|
||||
|
||||
|
||||
class ArticleUpdate(BaseModel):
|
||||
"""Schema for updating an article."""
|
||||
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=200)
|
||||
content: Optional[str] = Field(None, min_length=1)
|
||||
published: Optional[bool] = None
|
||||
|
||||
|
||||
class ArticleResponse(ArticleBase):
|
||||
"""Schema for article response."""
|
||||
|
||||
id: int
|
||||
author_id: int
|
||||
category_id: int
|
||||
created_at: datetime
|
||||
published: bool
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
Pydantic schemas for Author model.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
|
||||
class AuthorBase(BaseModel):
|
||||
"""Base author schema."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=100)
|
||||
email: EmailStr
|
||||
bio: Optional[str] = Field(None, max_length=1000)
|
||||
|
||||
|
||||
class AuthorCreate(AuthorBase):
|
||||
"""Schema for creating a new author."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class AuthorUpdate(BaseModel):
|
||||
"""Schema for updating an author."""
|
||||
|
||||
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
||||
email: Optional[EmailStr] = None
|
||||
bio: Optional[str] = Field(None, max_length=1000)
|
||||
|
||||
|
||||
class AuthorResponse(AuthorBase):
|
||||
"""Schema for author response."""
|
||||
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Pydantic schemas for Category model.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class CategoryBase(BaseModel):
|
||||
"""Base category schema."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=100)
|
||||
slug: str = Field(..., min_length=1, max_length=100)
|
||||
|
||||
|
||||
class CategoryCreate(CategoryBase):
|
||||
"""Schema for creating a new category."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class CategoryUpdate(BaseModel):
|
||||
"""Schema for updating a category."""
|
||||
|
||||
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
||||
slug: Optional[str] = Field(None, min_length=1, max_length=100)
|
||||
|
||||
|
||||
class CategoryResponse(CategoryBase):
|
||||
"""Schema for category response."""
|
||||
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in new issue
Block a user