Big refactor of gift categories model
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped

This commit is contained in:
2025-03-16 14:51:04 +01:00
parent ed017a42ed
commit 4ef202cc5a
7 changed files with 643 additions and 97 deletions

View File

@@ -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