mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 04:11:12 -05:00
Implement entity submission services for ThrillWiki
- Added BaseEntitySubmissionService as an abstract base for entity submissions. - Created specific submission services for entities: Park, Ride, Company, RideModel. - Implemented create, update, and delete functionalities with moderation workflow. - Enhanced logging and validation for required fields. - Addressed foreign key handling and special field processing for each entity type. - Noted existing issues with JSONField usage in Company submissions.
This commit is contained in:
@@ -1169,3 +1169,120 @@ class TopListListOut(BaseModel):
|
||||
class ReorderItemsRequest(BaseModel):
|
||||
"""Schema for reordering list items."""
|
||||
item_positions: dict = Field(..., description="Map of item_id to new_position")
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# History/Versioning Schemas
|
||||
# ============================================================================
|
||||
|
||||
class HistoryEventSchema(BaseModel):
|
||||
"""Schema for a single history event."""
|
||||
id: int
|
||||
timestamp: datetime
|
||||
operation: str # 'INSERT' or 'UPDATE'
|
||||
snapshot: dict
|
||||
changed_fields: Optional[dict] = None
|
||||
change_summary: str
|
||||
can_rollback: bool
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class HistoryListResponse(BaseModel):
|
||||
"""Response for list history endpoint."""
|
||||
entity_id: UUID
|
||||
entity_type: str
|
||||
entity_name: str
|
||||
total_events: int
|
||||
accessible_events: int
|
||||
access_limited: bool
|
||||
access_reason: str
|
||||
events: List[HistoryEventSchema]
|
||||
pagination: dict
|
||||
|
||||
|
||||
class HistoryEventDetailSchema(BaseModel):
|
||||
"""Detailed event with rollback preview."""
|
||||
id: int
|
||||
timestamp: datetime
|
||||
operation: str
|
||||
entity_id: UUID
|
||||
entity_type: str
|
||||
entity_name: str
|
||||
snapshot: dict
|
||||
changed_fields: Optional[dict] = None
|
||||
metadata: dict
|
||||
can_rollback: bool
|
||||
rollback_preview: Optional[dict] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class HistoryComparisonSchema(BaseModel):
|
||||
"""Response for event comparison."""
|
||||
entity_id: UUID
|
||||
entity_type: str
|
||||
entity_name: str
|
||||
event1: dict
|
||||
event2: dict
|
||||
differences: dict
|
||||
changed_field_count: int
|
||||
unchanged_field_count: int
|
||||
time_between: str
|
||||
|
||||
|
||||
class HistoryDiffCurrentSchema(BaseModel):
|
||||
"""Response for comparing event with current state."""
|
||||
entity_id: UUID
|
||||
entity_type: str
|
||||
entity_name: str
|
||||
event: dict
|
||||
current_state: dict
|
||||
differences: dict
|
||||
changed_field_count: int
|
||||
time_since: str
|
||||
|
||||
|
||||
class FieldHistorySchema(BaseModel):
|
||||
"""Response for field-specific history."""
|
||||
entity_id: UUID
|
||||
entity_type: str
|
||||
entity_name: str
|
||||
field: str
|
||||
field_type: str
|
||||
history: List[dict]
|
||||
total_changes: int
|
||||
first_value: Optional[str] = None
|
||||
current_value: Optional[str] = None
|
||||
|
||||
|
||||
class HistoryActivitySummarySchema(BaseModel):
|
||||
"""Response for activity summary."""
|
||||
entity_id: UUID
|
||||
entity_type: str
|
||||
entity_name: str
|
||||
total_events: int
|
||||
accessible_events: int
|
||||
summary: dict
|
||||
most_changed_fields: Optional[List[dict]] = None
|
||||
recent_activity: List[dict]
|
||||
|
||||
|
||||
class RollbackRequestSchema(BaseModel):
|
||||
"""Request body for rollback operation."""
|
||||
fields: Optional[List[str]] = None
|
||||
comment: str = ""
|
||||
create_backup: bool = True
|
||||
|
||||
|
||||
class RollbackResponseSchema(BaseModel):
|
||||
"""Response for rollback operation."""
|
||||
success: bool
|
||||
message: str
|
||||
entity_id: UUID
|
||||
rollback_event_id: int
|
||||
new_event_id: Optional[int]
|
||||
fields_changed: dict
|
||||
backup_event_id: Optional[int]
|
||||
|
||||
Reference in New Issue
Block a user