feat: add platform detail/edit admin UI and service enhancements

- Add platform detail and edit admin pages with templates and JS
- Add ContentPageService methods: list_all_platform_pages, list_all_vendor_defaults
- Deprecate /admin/platform-homepage route (redirects to /admin/platforms)
- Add migration to fix content_page nullable columns
- Refine platform and vendor context middleware
- Add platform context middleware unit tests
- Update platforms.js with improved functionality
- Add section-based homepage plan documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 14:08:02 +01:00
parent d70a9f38d4
commit 3d3b8cae22
25 changed files with 3233 additions and 95 deletions

View File

@@ -91,7 +91,7 @@ class VendorContextManager:
# Method 3: Path-based detection (/vendor/vendorname/ or /vendors/vendorname/)
# Support BOTH patterns for flexibility
if path.startswith("/vendor/") or path.startswith("/vendors/"):
if path.startswith(("/vendor/", "/vendors/")):
# Determine which pattern
if path.startswith("/vendors/"):
prefix_len = len("/vendors/")
@@ -133,8 +133,8 @@ class VendorContextManager:
vendor_domain = (
db.query(VendorDomain)
.filter(VendorDomain.domain == domain)
.filter(VendorDomain.is_active == True)
.filter(VendorDomain.is_verified == True)
.filter(VendorDomain.is_active.is_(True))
.filter(VendorDomain.is_verified.is_(True))
.first()
)
@@ -157,7 +157,7 @@ class VendorContextManager:
vendor = (
db.query(Vendor)
.filter(func.lower(Vendor.subdomain) == subdomain.lower())
.filter(Vendor.is_active == True)
.filter(Vendor.is_active.is_(True))
.first()
)
@@ -204,10 +204,7 @@ class VendorContextManager:
if host.startswith("admin."):
return True
if path.startswith("/admin"):
return True
return False
return path.startswith("/admin")
@staticmethod
def is_api_request(request: Request) -> bool:
@@ -263,9 +260,7 @@ class VendorContextManager:
# Method 1: Path-based detection from referer path
# /vendors/wizamart/shop/products → wizamart
if referer_path.startswith("/vendors/") or referer_path.startswith(
"/vendor/"
):
if referer_path.startswith(("/vendors/", "/vendor/")):
prefix = (
"/vendors/" if referer_path.startswith("/vendors/") else "/vendor/"
)
@@ -384,10 +379,7 @@ class VendorContextManager:
if any(path.startswith(static_path) for static_path in static_paths):
return True
if "favicon.ico" in path:
return True
return False
return "favicon.ico" in path
class VendorContextMiddleware(BaseHTTPMiddleware):