new init
This commit is contained in:
32
apps/backend/app/schemas/topup.py
Normal file
32
apps/backend/app/schemas/topup.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
|
||||
class TopupStatus(str, Enum):
|
||||
pending = "pending"
|
||||
confirmed = "confirmed"
|
||||
rejected = "rejected"
|
||||
|
||||
# Für Ausgaben und Admin-Create weiterhin kompatibel:
|
||||
class TopupBase(BaseModel):
|
||||
user_id: Optional[int] = None # <- optional gemacht
|
||||
amount_cents: int
|
||||
paypal_email: Optional[str] = None
|
||||
note: Optional[str] = None
|
||||
|
||||
class TopupCreate(TopupBase):
|
||||
# user_id kann für Admin-Aufrufe gesetzt werden, für User-Create weggelassen
|
||||
pass
|
||||
|
||||
class TopupStatusUpdate(BaseModel):
|
||||
status: TopupStatus
|
||||
|
||||
class TopupOut(TopupBase):
|
||||
id: int
|
||||
status: TopupStatus
|
||||
created_at: datetime
|
||||
confirmed_at: Optional[datetime] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True # pydantic v2 (ersetzt orm_mode)
|
Reference in New Issue
Block a user