feat(admin): separate platform CRUD from CMS, add entity selector macro
Some checks failed
Some checks failed
- Move platforms menu from CMS to Platform Admin section with create/edit - Add platform create page, API endpoint, and service method - Remove CMS-specific content from platform list and detail pages - Create shared entity_selector + entity_selected_badge Jinja macros - Create entity-selector.js generalizing store-selector.js for any entity - Add Tom Select merchant filter to stores page with localStorage persistence - Migrate store-products page to use shared macros (remove 53 lines of duped CSS) - Fix broken icons: puzzle→puzzle-piece, building-storefront→store, language→translate, server→cube Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -91,6 +91,21 @@ class PlatformUpdateRequest(BaseModel):
|
||||
settings: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class PlatformCreateRequest(BaseModel):
|
||||
"""Request schema for creating a platform."""
|
||||
|
||||
code: str = Field(..., min_length=2, max_length=50, pattern=r"^[a-z][a-z0-9_-]*$")
|
||||
name: str = Field(..., min_length=1, max_length=100)
|
||||
description: str | None = None
|
||||
description_translations: dict[str, str] | None = None
|
||||
domain: str | None = None
|
||||
path_prefix: str | None = None
|
||||
default_language: str = "fr"
|
||||
supported_languages: list[str] = Field(default_factory=lambda: ["fr", "de", "en", "lb"])
|
||||
is_active: bool = True
|
||||
is_public: bool = True
|
||||
|
||||
|
||||
class PlatformStatsResponse(BaseModel):
|
||||
"""Platform statistics response."""
|
||||
|
||||
@@ -162,6 +177,26 @@ async def list_platforms(
|
||||
return PlatformListResponse(platforms=result, total=len(result))
|
||||
|
||||
|
||||
@admin_platforms_router.post("", response_model=PlatformResponse, status_code=201)
|
||||
async def create_platform(
|
||||
create_data: PlatformCreateRequest,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: UserContext = Depends(get_current_admin_from_cookie_or_header),
|
||||
):
|
||||
"""
|
||||
Create a new platform.
|
||||
|
||||
Creates a new platform with the provided configuration.
|
||||
"""
|
||||
data = create_data.model_dump()
|
||||
platform = platform_service.create_platform(db, data)
|
||||
db.commit()
|
||||
db.refresh(platform)
|
||||
|
||||
logger.info(f"[PLATFORMS] Created platform: {platform.code}")
|
||||
return _build_platform_response(db, platform)
|
||||
|
||||
|
||||
@admin_platforms_router.get("/{code}", response_model=PlatformResponse)
|
||||
async def get_platform(
|
||||
code: str = Path(..., description="Platform code (oms, loyalty, etc.)"),
|
||||
|
||||
Reference in New Issue
Block a user