#!/usr/bin/env python3 """ Create Platform Content Pages This script creates default platform-level content pages: - Platform Homepage (slug='platform_homepage') - About Us (slug='about') - FAQ (slug='faq') - Terms of Service (slug='terms') - Privacy Policy (slug='privacy') - Contact Us (slug='contact') All pages are created with store_id=NULL (platform-level defaults). Usage: python scripts/create_platform_pages.py """ import sys from pathlib import Path # Add project root to path project_root = Path(__file__).resolve().parent.parent sys.path.insert(0, str(project_root)) # Register all models with SQLAlchemy so string-based relationships resolve for _mod in [ "app.modules.billing.models", "app.modules.inventory.models", "app.modules.cart.models", "app.modules.messaging.models", "app.modules.loyalty.models", "app.modules.catalog.models", "app.modules.customers.models", "app.modules.orders.models", "app.modules.marketplace.models", "app.modules.cms.models", ]: try: __import__(_mod) except ImportError: pass from sqlalchemy import select from app.core.database import SessionLocal from app.modules.cms.services import content_page_service from app.modules.tenancy.models import Platform def create_platform_pages(): """Create default platform content pages.""" db = SessionLocal() try: print("=" * 80) print("CREATING PLATFORM CONTENT PAGES") print("=" * 80) print() # Import ContentPage for checking existing pages from app.modules.cms.models import ContentPage # Resolve OMS platform oms_platform = db.execute( select(Platform).where(Platform.code == "oms") ).scalar_one_or_none() if not oms_platform: print(" ⚠️ OMS platform not found. Run init_production.py first.") return platform_id = oms_platform.id # ======================================================================== # 1. PLATFORM HOMEPAGE # ======================================================================== print("1. Creating Platform Homepage...") # Check if already exists existing = ( db.query(ContentPage) .filter_by(store_id=None, slug="platform_homepage") .first() ) if existing: print( f" ⚠️ Skipped: Platform Homepage - already exists (ID: {existing.id})" ) else: try: homepage = content_page_service.create_page( db, platform_id=platform_id, slug="platform_homepage", title="Welcome to Our Multi-Store Marketplace", content="""
Connect stores with customers worldwide. Build your online store and reach millions of shoppers.
Our platform empowers entrepreneurs to launch their own branded e-commerce stores with minimal effort and maximum impact.
""", template="modern", # Uses platform/homepage-modern.html store_id=None, # Platform-level page is_published=True, show_in_header=False, # Homepage is not in menu (it's the root) show_in_footer=False, display_order=0, meta_description="Leading multi-store marketplace platform. Connect with thousands of stores and discover millions of products.", meta_keywords="marketplace, multi-store, e-commerce, online shopping, platform", ) print(f" ✅ Created: {homepage.title} (/{homepage.slug})") except Exception as e: print(f" ⚠️ Error: Platform Homepage - {str(e)}") # ======================================================================== # 2. ABOUT US # ======================================================================== print("2. Creating About Us page...") existing = db.query(ContentPage).filter_by(store_id=None, slug="about").first() if existing: print(f" ⚠️ Skipped: About Us - already exists (ID: {existing.id})") else: try: about = content_page_service.create_page( db, platform_id=platform_id, slug="about", title="About Us", content="""We're on a mission to democratize e-commerce by providing powerful, easy-to-use tools for entrepreneurs worldwide.
Founded in 2024, our platform has grown to serve over 10,000 active stores and millions of customers around the globe. We believe that everyone should have the opportunity to build and grow their own online business.
Contact our sales team to get started. We'll set up your account and provide you with everything you need to launch your store.
Most stores can launch their store in less than 24 hours. Our team will guide you through the setup process step by step.
We offer flexible pricing plans based on your business needs. Contact us for detailed pricing information and to find the plan that's right for you.
Payments are processed weekly, with funds typically reaching your account within 2-3 business days.
Yes! Our platform supports full theme customization including colors, fonts, logos, and layouts. Make your store truly yours.
We offer 24/7 email support for all stores, with priority phone support available for enterprise plans.
No! Our platform is designed to be user-friendly for everyone. However, if you want to customize advanced features, our documentation and support team are here to help.
Yes, we support integrations with popular payment gateways, shipping providers, and marketing tools.
""", store_id=None, is_published=True, show_in_header=True, # Show in header navigation show_in_footer=True, display_order=2, meta_description="Find answers to common questions about our marketplace platform.", meta_keywords="faq, frequently asked questions, help, support", ) print(f" ✅ Created: {faq.title} (/{faq.slug})") except Exception as e: print(f" ⚠️ Error: FAQ - {str(e)}") # ======================================================================== # 4. CONTACT US # ======================================================================== print("4. Creating Contact Us page...") existing = ( db.query(ContentPage).filter_by(store_id=None, slug="contact").first() ) if existing: print(f" ⚠️ Skipped: Contact Us - already exists (ID: {existing.id})") else: try: contact = content_page_service.create_page( db, platform_id=platform_id, slug="contact", title="Contact Us", content="""We'd love to hear from you! Whether you have questions about our platform, need technical support, or want to discuss partnership opportunities, our team is here to help.
123 Business Street, Suite 100
San Francisco, CA 94102
United States
Interested in launching your store on our platform?
Email: sales@marketplace.com
Need help with your store?
Email: support@marketplace.com
24/7 email support for all stores
For media inquiries and press releases:
Email: press@marketplace.com
Last updated: January 1, 2024
By accessing and using this marketplace platform, you accept and agree to be bound by the terms and provisions of this agreement.
Permission is granted to temporarily access the materials on our platform for personal, non-commercial transitory viewing only.
You may not use our platform to:
We reserve the right to terminate or suspend your account at any time for violation of these terms.
In no event shall our merchant be liable for any damages arising out of the use or inability to use our platform.
We reserve the right to modify these terms at any time. We will notify users of any changes via email.
If you have any questions about these Terms, please contact us at legal@marketplace.com.
""", store_id=None, is_published=True, show_in_header=False, # Too legal for header show_in_footer=True, # Show in footer display_order=10, meta_description="Read our terms of service and platform usage policies.", meta_keywords="terms of service, terms, legal, policy, agreement", ) print(f" ✅ Created: {terms.title} (/{terms.slug})") except Exception as e: print(f" ⚠️ Error: Terms of Service - {str(e)}") # ======================================================================== # 6. PRIVACY POLICY # ======================================================================== print("6. Creating Privacy Policy page...") existing = ( db.query(ContentPage).filter_by(store_id=None, slug="privacy").first() ) if existing: print(f" ⚠️ Skipped: Privacy Policy - already exists (ID: {existing.id})") else: try: privacy = content_page_service.create_page( db, platform_id=platform_id, slug="privacy", title="Privacy Policy", content="""Last updated: January 1, 2024
We collect information you provide directly to us, including:
We use the information we collect to:
We do not sell your personal information. We may share information with:
We implement appropriate security measures to protect your personal information. However, no method of transmission over the internet is 100% secure.
You have the right to:
We use cookies and similar tracking technologies to track activity on our platform and hold certain information. You can instruct your browser to refuse cookies.
We may update this privacy policy from time to time. We will notify you of any changes by posting the new policy on this page.
If you have questions about this Privacy Policy, please contact us at privacy@marketplace.com.
""", store_id=None, is_published=True, show_in_header=False, # Too legal for header show_in_footer=True, # Show in footer display_order=11, meta_description="Learn how we collect, use, and protect your personal information.", meta_keywords="privacy policy, privacy, data protection, gdpr, personal information", ) print(f" ✅ Created: {privacy.title} (/{privacy.slug})") except Exception as e: print(f" ⚠️ Error: Privacy Policy - {str(e)}") db.commit() print() print("=" * 80) print("✅ Platform pages creation completed successfully!") print("=" * 80) print() print("Created pages:") print(" - Platform Homepage: http://localhost:8000/") print(" - About Us: http://localhost:8000/about") print(" - FAQ: http://localhost:8000/faq") print(" - Contact Us: http://localhost:8000/contact") print(" - Terms of Service: http://localhost:8000/terms") print(" - Privacy Policy: http://localhost:8000/privacy") print() except Exception as e: print(f"\n❌ Error: {e}") db.rollback() raise finally: db.close() if __name__ == "__main__": create_platform_pages()