Big refactor of gift categories model
This commit is contained in:
@@ -123,7 +123,6 @@ class GiftCategoryBase(BaseModel):
|
||||
|
||||
# Schema for creating a category
|
||||
class GiftCategoryCreate(GiftCategoryBase):
|
||||
event_id: UUID
|
||||
created_by: UUID
|
||||
|
||||
|
||||
@@ -133,15 +132,12 @@ class GiftCategoryUpdate(BaseModel):
|
||||
description: Optional[str] = None
|
||||
icon: Optional[str] = None
|
||||
color: Optional[str] = None
|
||||
display_order: Optional[int] = None
|
||||
is_visible: Optional[bool] = None
|
||||
custom_fields: Optional[Dict[str, Any]] = None
|
||||
|
||||
|
||||
# Schema for reading a category
|
||||
class GiftCategoryInDB(GiftCategoryBase):
|
||||
id: UUID
|
||||
event_id: UUID
|
||||
created_by: UUID
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
@@ -150,11 +146,42 @@ class GiftCategoryInDB(GiftCategoryBase):
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# Event-Category association schemas
|
||||
class EventGiftCategoryBase(BaseModel):
|
||||
event_id: UUID
|
||||
category_id: UUID
|
||||
display_order: int = 0
|
||||
is_visible: bool = True
|
||||
|
||||
|
||||
# Schema for creating an event-category association
|
||||
class EventGiftCategoryCreate(EventGiftCategoryBase):
|
||||
pass
|
||||
|
||||
|
||||
# Schema for updating an event-category association
|
||||
class EventGiftCategoryUpdate(BaseModel):
|
||||
display_order: Optional[int] = None
|
||||
is_visible: Optional[bool] = None
|
||||
|
||||
|
||||
# Schema for reading an event-category association
|
||||
class EventGiftCategoryInDB(EventGiftCategoryBase):
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# Public category response with statistics
|
||||
class GiftCategory(GiftCategoryInDB):
|
||||
total_gifts: int
|
||||
available_gifts: int
|
||||
# These properties will be calculated for a specific event in the API
|
||||
total_gifts: Optional[int] = None
|
||||
available_gifts: Optional[int] = None
|
||||
gifts: Optional[List[GiftItem]] = None
|
||||
# For display in a specific event context
|
||||
display_order: Optional[int] = None
|
||||
is_visible: Optional[bool] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
@@ -195,4 +222,4 @@ class GiftPurchaseInDB(GiftPurchaseBase):
|
||||
# Public gift purchase response
|
||||
class GiftPurchase(GiftPurchaseInDB):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
from_attributes = True
|
||||
|
||||
Reference in New Issue
Block a user