initial commit - LeDiscord plateforme des copains
This commit is contained in:
21
backend/schemas/__init__.py
Normal file
21
backend/schemas/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from .user import UserCreate, UserUpdate, UserResponse, UserLogin, Token
|
||||
from .event import EventCreate, EventUpdate, EventResponse, ParticipationUpdate
|
||||
from .album import AlbumCreate, AlbumUpdate, AlbumResponse, MediaResponse, MediaLikeResponse
|
||||
from .post import PostCreate, PostUpdate, PostResponse
|
||||
from .vlog import VlogCreate, VlogUpdate, VlogResponse, VlogCommentCreate, VlogLikeResponse, VlogCommentResponse
|
||||
from .notification import NotificationResponse
|
||||
from .settings import SystemSettingCreate, SystemSettingUpdate, SystemSettingResponse, SettingsCategoryResponse, UploadLimitsResponse
|
||||
from .information import InformationCreate, InformationUpdate, InformationResponse
|
||||
from .ticket import TicketCreate, TicketUpdate, TicketResponse, TicketAdminUpdate
|
||||
|
||||
__all__ = [
|
||||
"UserCreate", "UserUpdate", "UserResponse", "UserLogin", "Token",
|
||||
"EventCreate", "EventUpdate", "EventResponse", "ParticipationUpdate",
|
||||
"AlbumCreate", "AlbumUpdate", "AlbumResponse", "MediaResponse", "MediaLikeResponse",
|
||||
"PostCreate", "PostUpdate", "PostResponse",
|
||||
"VlogCreate", "VlogUpdate", "VlogResponse", "VlogCommentCreate", "VlogLikeResponse", "VlogCommentResponse",
|
||||
"NotificationResponse",
|
||||
"SystemSettingCreate", "SystemSettingUpdate", "SystemSettingResponse", "SettingsCategoryResponse", "UploadLimitsResponse",
|
||||
"InformationCreate", "InformationUpdate", "InformationResponse",
|
||||
"TicketCreate", "TicketUpdate", "TicketResponse", "TicketAdminUpdate"
|
||||
]
|
||||
61
backend/schemas/album.py
Normal file
61
backend/schemas/album.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
from models.album import MediaType
|
||||
|
||||
class AlbumBase(BaseModel):
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
event_id: Optional[int] = None
|
||||
|
||||
class AlbumCreate(AlbumBase):
|
||||
cover_image: Optional[str] = None
|
||||
|
||||
class AlbumUpdate(BaseModel):
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
event_id: Optional[int] = None
|
||||
cover_image: Optional[str] = None
|
||||
|
||||
class MediaLikeResponse(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
username: str
|
||||
full_name: str
|
||||
avatar_url: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class MediaResponse(BaseModel):
|
||||
id: int
|
||||
file_path: str
|
||||
thumbnail_path: Optional[str]
|
||||
media_type: MediaType
|
||||
caption: Optional[str]
|
||||
file_size: int
|
||||
width: Optional[int]
|
||||
height: Optional[int]
|
||||
duration: Optional[int]
|
||||
likes_count: int
|
||||
is_liked: Optional[bool] = None
|
||||
likes: List[MediaLikeResponse] = []
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class AlbumResponse(AlbumBase):
|
||||
id: int
|
||||
creator_id: int
|
||||
creator_name: str
|
||||
cover_image: Optional[str]
|
||||
created_at: datetime
|
||||
media_count: int = 0
|
||||
media: List[MediaResponse] = []
|
||||
event_title: Optional[str] = None
|
||||
top_media: List[MediaResponse] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
55
backend/schemas/event.py
Normal file
55
backend/schemas/event.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
from models.event import ParticipationStatus
|
||||
|
||||
class EventBase(BaseModel):
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
location: Optional[str] = None
|
||||
latitude: Optional[float] = None
|
||||
longitude: Optional[float] = None
|
||||
date: datetime
|
||||
end_date: Optional[datetime] = None
|
||||
|
||||
class EventCreate(EventBase):
|
||||
cover_image: Optional[str] = None
|
||||
|
||||
class EventUpdate(BaseModel):
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
location: Optional[str] = None
|
||||
latitude: Optional[float] = None
|
||||
longitude: Optional[float] = None
|
||||
date: Optional[datetime] = None
|
||||
end_date: Optional[datetime] = None
|
||||
cover_image: Optional[str] = None
|
||||
|
||||
class ParticipationResponse(BaseModel):
|
||||
user_id: int
|
||||
username: str
|
||||
full_name: str
|
||||
avatar_url: Optional[str]
|
||||
status: ParticipationStatus
|
||||
response_date: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class EventResponse(EventBase):
|
||||
id: int
|
||||
creator_id: int
|
||||
creator_name: str
|
||||
cover_image: Optional[str]
|
||||
created_at: datetime
|
||||
participations: List[ParticipationResponse] = []
|
||||
present_count: int = 0
|
||||
absent_count: int = 0
|
||||
maybe_count: int = 0
|
||||
pending_count: int = 0
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class ParticipationUpdate(BaseModel):
|
||||
status: ParticipationStatus
|
||||
28
backend/schemas/information.py
Normal file
28
backend/schemas/information.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
class InformationBase(BaseModel):
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
content: str = Field(..., min_length=1)
|
||||
category: str = Field(default="general")
|
||||
is_published: bool = Field(default=True)
|
||||
priority: int = Field(default=0, ge=0)
|
||||
|
||||
class InformationCreate(InformationBase):
|
||||
pass
|
||||
|
||||
class InformationUpdate(BaseModel):
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=200)
|
||||
content: Optional[str] = Field(None, min_length=1)
|
||||
category: Optional[str] = None
|
||||
is_published: Optional[bool] = None
|
||||
priority: Optional[int] = Field(None, ge=0)
|
||||
|
||||
class InformationResponse(InformationBase):
|
||||
id: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
17
backend/schemas/notification.py
Normal file
17
backend/schemas/notification.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from models.notification import NotificationType
|
||||
|
||||
class NotificationResponse(BaseModel):
|
||||
id: int
|
||||
type: NotificationType
|
||||
title: str
|
||||
message: str
|
||||
link: Optional[str]
|
||||
is_read: bool
|
||||
created_at: datetime
|
||||
read_at: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
54
backend/schemas/post.py
Normal file
54
backend/schemas/post.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
|
||||
class PostBase(BaseModel):
|
||||
content: str = Field(..., min_length=1, max_length=5000)
|
||||
|
||||
class PostCreate(PostBase):
|
||||
image_url: Optional[str] = None
|
||||
mentioned_user_ids: List[int] = []
|
||||
|
||||
class PostUpdate(BaseModel):
|
||||
content: Optional[str] = Field(None, min_length=1, max_length=5000)
|
||||
image_url: Optional[str] = None
|
||||
|
||||
class PostCommentCreate(BaseModel):
|
||||
content: str = Field(..., min_length=1, max_length=500)
|
||||
|
||||
class MentionedUser(BaseModel):
|
||||
id: int
|
||||
username: str
|
||||
full_name: str
|
||||
avatar_url: Optional[str]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class PostCommentResponse(BaseModel):
|
||||
id: int
|
||||
content: str
|
||||
author_id: int
|
||||
author_name: str
|
||||
author_avatar: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class PostResponse(PostBase):
|
||||
id: int
|
||||
author_id: int
|
||||
author_name: str
|
||||
author_avatar: Optional[str]
|
||||
image_url: Optional[str]
|
||||
likes_count: int = 0
|
||||
comments_count: int = 0
|
||||
is_liked: Optional[bool] = None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
mentioned_users: List[MentionedUser] = []
|
||||
comments: List[PostCommentResponse] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
40
backend/schemas/settings.py
Normal file
40
backend/schemas/settings.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, Dict, Any
|
||||
from datetime import datetime
|
||||
|
||||
class SystemSettingBase(BaseModel):
|
||||
key: str = Field(..., description="Clé unique du paramètre")
|
||||
value: str = Field(..., description="Valeur du paramètre")
|
||||
description: Optional[str] = Field(None, description="Description du paramètre")
|
||||
category: str = Field(default="general", description="Catégorie du paramètre")
|
||||
|
||||
class SystemSettingCreate(SystemSettingBase):
|
||||
pass
|
||||
|
||||
class SystemSettingUpdate(BaseModel):
|
||||
value: str = Field(..., description="Nouvelle valeur du paramètre")
|
||||
|
||||
class SystemSettingResponse(SystemSettingBase):
|
||||
id: int
|
||||
is_editable: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class SettingsCategoryResponse(BaseModel):
|
||||
category: str
|
||||
settings: list[SystemSettingResponse]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class UploadLimitsResponse(BaseModel):
|
||||
max_album_size_mb: int
|
||||
max_vlog_size_mb: int
|
||||
max_image_size_mb: int
|
||||
max_video_size_mb: int
|
||||
max_media_per_album: int
|
||||
allowed_image_types: list[str]
|
||||
allowed_video_types: list[str]
|
||||
47
backend/schemas/ticket.py
Normal file
47
backend/schemas/ticket.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from models.ticket import TicketType, TicketStatus, TicketPriority
|
||||
|
||||
class TicketBase(BaseModel):
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
description: str = Field(..., min_length=1)
|
||||
ticket_type: TicketType = Field(default=TicketType.OTHER)
|
||||
priority: TicketPriority = Field(default=TicketPriority.MEDIUM)
|
||||
|
||||
class TicketCreate(TicketBase):
|
||||
pass
|
||||
|
||||
class TicketUpdate(BaseModel):
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=200)
|
||||
description: Optional[str] = Field(None, min_length=1)
|
||||
ticket_type: Optional[TicketType] = None
|
||||
status: Optional[TicketStatus] = None
|
||||
priority: Optional[TicketPriority] = None
|
||||
assigned_to: Optional[int] = None
|
||||
admin_notes: Optional[str] = None
|
||||
|
||||
class TicketResponse(TicketBase):
|
||||
id: int
|
||||
status: TicketStatus
|
||||
user_id: int
|
||||
assigned_to: Optional[int]
|
||||
screenshot_path: Optional[str]
|
||||
admin_notes: Optional[str]
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
resolved_at: Optional[datetime]
|
||||
|
||||
# User information
|
||||
user_name: str
|
||||
user_email: str
|
||||
assigned_admin_name: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class TicketAdminUpdate(BaseModel):
|
||||
status: Optional[TicketStatus] = None
|
||||
priority: Optional[TicketPriority] = None
|
||||
assigned_to: Optional[int] = None
|
||||
admin_notes: Optional[str] = None
|
||||
41
backend/schemas/user.py
Normal file
41
backend/schemas/user.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
class UserBase(BaseModel):
|
||||
email: EmailStr
|
||||
username: str = Field(..., min_length=3, max_length=50)
|
||||
full_name: str = Field(..., min_length=1, max_length=100)
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str = Field(..., min_length=6)
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
full_name: Optional[str] = Field(None, min_length=1, max_length=100)
|
||||
bio: Optional[str] = Field(None, max_length=500)
|
||||
avatar_url: Optional[str] = None
|
||||
|
||||
class UserResponse(UserBase):
|
||||
id: int
|
||||
is_active: bool
|
||||
is_admin: bool
|
||||
avatar_url: Optional[str]
|
||||
bio: Optional[str]
|
||||
attendance_rate: float
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class UserLogin(BaseModel):
|
||||
email: EmailStr
|
||||
password: str
|
||||
|
||||
class Token(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
user: UserResponse
|
||||
|
||||
class TokenData(BaseModel):
|
||||
user_id: Optional[int] = None
|
||||
email: Optional[str] = None
|
||||
63
backend/schemas/vlog.py
Normal file
63
backend/schemas/vlog.py
Normal file
@@ -0,0 +1,63 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
|
||||
class VlogBase(BaseModel):
|
||||
title: str = Field(..., min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
|
||||
class VlogCreate(VlogBase):
|
||||
video_url: str
|
||||
thumbnail_url: Optional[str] = None
|
||||
duration: Optional[int] = None
|
||||
|
||||
class VlogUpdate(BaseModel):
|
||||
title: Optional[str] = Field(None, min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
thumbnail_url: Optional[str] = None
|
||||
|
||||
class VlogLikeResponse(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
username: str
|
||||
full_name: str
|
||||
avatar_url: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class VlogCommentResponse(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
username: str
|
||||
full_name: str
|
||||
avatar_url: Optional[str]
|
||||
content: str
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class VlogResponse(VlogBase):
|
||||
id: int
|
||||
author_id: int
|
||||
author_name: str
|
||||
author_avatar: Optional[str]
|
||||
video_url: str
|
||||
thumbnail_url: Optional[str]
|
||||
duration: Optional[int]
|
||||
views_count: int
|
||||
likes_count: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
is_liked: Optional[bool] = None
|
||||
likes: List[VlogLikeResponse] = []
|
||||
comments: List[VlogCommentResponse] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class VlogCommentCreate(BaseModel):
|
||||
content: str = Field(..., min_length=1, max_length=1000)
|
||||
Reference in New Issue
Block a user