Templates Migration: - Migrate admin templates to modules (tenancy, billing, monitoring, marketplace, etc.) - Migrate vendor templates to modules (tenancy, billing, orders, messaging, etc.) - Migrate storefront templates to modules (catalog, customers, orders, cart, checkout, cms) - Migrate public templates to modules (billing, marketplace, cms) - Keep shared templates in app/templates/ (base.html, errors/, partials/, macros/) - Migrate letzshop partials to marketplace module Static Files Migration: - Migrate admin JS to modules: tenancy (23 files), core (5 files), monitoring (1 file) - Migrate vendor JS to modules: tenancy (4 files), core (2 files) - Migrate shared JS: vendor-selector.js to core, media-picker.js to cms - Migrate storefront JS: storefront-layout.js to core - Keep framework JS in static/ (api-client, utils, money, icons, log-config, lib/) - Update all template references to use module_static paths Naming Consistency: - Rename static/platform/ to static/public/ - Rename app/templates/platform/ to app/templates/public/ - Update all extends and static references Documentation: - Update module-system.md with shared templates documentation - Update frontend-structure.md with new module JS organization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
3.3 KiB
Python
98 lines
3.3 KiB
Python
# app/modules/tenancy/routes/api/vendor.py
|
|
"""
|
|
Tenancy module vendor API routes.
|
|
|
|
Aggregates all vendor tenancy routes:
|
|
- /info/{vendor_code} - Public vendor info lookup
|
|
- /auth/* - Vendor authentication (login, logout, /me)
|
|
- /profile/* - Vendor profile management
|
|
- /team/* - Team member management, roles, permissions
|
|
|
|
The tenancy module owns identity and organizational hierarchy.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from fastapi import APIRouter, Depends, Path
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import get_db
|
|
from app.modules.tenancy.services.vendor_service import vendor_service # noqa: mod-004
|
|
from models.schema.vendor import VendorDetailResponse
|
|
|
|
vendor_router = APIRouter()
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@vendor_router.get("/info/{vendor_code}", response_model=VendorDetailResponse)
|
|
def get_vendor_info(
|
|
vendor_code: str = Path(..., description="Vendor code"),
|
|
db: Session = Depends(get_db),
|
|
):
|
|
"""
|
|
Get public vendor information by vendor code.
|
|
|
|
This endpoint is used by the vendor login page to display vendor info.
|
|
No authentication required - this is public information.
|
|
|
|
**Use Case:**
|
|
- Vendor login page loads vendor info to display branding
|
|
- Shows vendor name, description, logo, etc.
|
|
|
|
**Returns only active vendors** to prevent access to disabled accounts.
|
|
|
|
Args:
|
|
vendor_code: The vendor's unique code (e.g., 'WIZAMART')
|
|
db: Database session
|
|
|
|
Returns:
|
|
VendorResponse: Public vendor information
|
|
|
|
Raises:
|
|
VendorNotFoundException (404): Vendor not found or inactive
|
|
"""
|
|
logger.info(f"Public vendor info request: {vendor_code}")
|
|
|
|
vendor = vendor_service.get_active_vendor_by_code(db, vendor_code)
|
|
|
|
logger.info(f"Vendor info retrieved: {vendor.name} ({vendor.vendor_code})")
|
|
|
|
return VendorDetailResponse(
|
|
# Vendor fields
|
|
id=vendor.id,
|
|
vendor_code=vendor.vendor_code,
|
|
subdomain=vendor.subdomain,
|
|
name=vendor.name,
|
|
description=vendor.description,
|
|
company_id=vendor.company_id,
|
|
letzshop_csv_url_fr=vendor.letzshop_csv_url_fr,
|
|
letzshop_csv_url_en=vendor.letzshop_csv_url_en,
|
|
letzshop_csv_url_de=vendor.letzshop_csv_url_de,
|
|
is_active=vendor.is_active,
|
|
is_verified=vendor.is_verified,
|
|
created_at=vendor.created_at,
|
|
updated_at=vendor.updated_at,
|
|
# Company info
|
|
company_name=vendor.company.name,
|
|
company_contact_email=vendor.company.contact_email,
|
|
company_contact_phone=vendor.company.contact_phone,
|
|
company_website=vendor.company.website,
|
|
# Owner details (from company)
|
|
owner_email=vendor.company.owner.email,
|
|
owner_username=vendor.company.owner.username,
|
|
)
|
|
|
|
|
|
# ============================================================================
|
|
# Aggregate Sub-Routers
|
|
# ============================================================================
|
|
# Include all tenancy vendor routes (auth, profile, team)
|
|
|
|
from .vendor_auth import vendor_auth_router
|
|
from .vendor_profile import vendor_profile_router
|
|
from .vendor_team import vendor_team_router
|
|
|
|
vendor_router.include_router(vendor_auth_router, tags=["vendor-auth"])
|
|
vendor_router.include_router(vendor_profile_router, tags=["vendor-profile"])
|
|
vendor_router.include_router(vendor_team_router, tags=["vendor-team"])
|