#!/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="""

Our Mission

We're on a mission to democratize e-commerce by providing powerful, easy-to-use tools for entrepreneurs worldwide.

Our Story

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.

Why Choose Us?

Our Values

""", store_id=None, is_published=True, show_in_header=True, # Show in header navigation show_in_footer=True, # Show in footer display_order=1, meta_description="Learn about our mission to democratize e-commerce and empower entrepreneurs worldwide.", meta_keywords="about us, mission, vision, values, merchant", ) print(f" ✅ Created: {about.title} (/{about.slug})") except Exception as e: print(f" ⚠️ Error: About Us - {str(e)}") # ======================================================================== # 3. FAQ # ======================================================================== print("3. Creating FAQ page...") existing = db.query(ContentPage).filter_by(store_id=None, slug="faq").first() if existing: print(f" ⚠️ Skipped: FAQ - already exists (ID: {existing.id})") else: try: faq = content_page_service.create_page( db, platform_id=platform_id, slug="faq", title="Frequently Asked Questions", content="""

Getting Started

How do I create a store account?

Contact our sales team to get started. We'll set up your account and provide you with everything you need to launch your store.

How long does it take to set up my store?

Most stores can launch their store in less than 24 hours. Our team will guide you through the setup process step by step.

Pricing & Payment

What are your pricing plans?

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.

When do I get paid?

Payments are processed weekly, with funds typically reaching your account within 2-3 business days.

Features & Support

Can I customize my store's appearance?

Yes! Our platform supports full theme customization including colors, fonts, logos, and layouts. Make your store truly yours.

What kind of support do you provide?

We offer 24/7 email support for all stores, with priority phone support available for enterprise plans.

Technical Questions

Do I need technical knowledge to use the platform?

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.

Can I integrate with other tools?

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="""

Get in Touch

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.

Contact Information

Office Address

123 Business Street, Suite 100
San Francisco, CA 94102
United States

Sales Inquiries

Interested in launching your store on our platform?
Email: sales@marketplace.com

Technical Support

Need help with your store?
Email: support@marketplace.com
24/7 email support for all stores

Media & Press

For media inquiries and press releases:
Email: press@marketplace.com

""", store_id=None, is_published=True, show_in_header=True, # Show in header navigation show_in_footer=True, display_order=3, meta_description="Get in touch with our team. We're here to help you succeed.", meta_keywords="contact, support, email, phone, address", ) print(f" ✅ Created: {contact.title} (/{contact.slug})") except Exception as e: print(f" ⚠️ Error: Contact Us - {str(e)}") # ======================================================================== # 5. TERMS OF SERVICE # ======================================================================== print("5. Creating Terms of Service page...") existing = db.query(ContentPage).filter_by(store_id=None, slug="terms").first() if existing: print( f" ⚠️ Skipped: Terms of Service - already exists (ID: {existing.id})" ) else: try: terms = content_page_service.create_page( db, platform_id=platform_id, slug="terms", title="Terms of Service", content="""

Last updated: January 1, 2024

1. Acceptance of Terms

By accessing and using this marketplace platform, you accept and agree to be bound by the terms and provisions of this agreement.

2. Use License

Permission is granted to temporarily access the materials on our platform for personal, non-commercial transitory viewing only.

3. Account Terms

4. Store Responsibilities

5. Prohibited Activities

You may not use our platform to:

6. Termination

We reserve the right to terminate or suspend your account at any time for violation of these terms.

7. Limitation of Liability

In no event shall our merchant be liable for any damages arising out of the use or inability to use our platform.

8. Changes to Terms

We reserve the right to modify these terms at any time. We will notify users of any changes via email.

9. Contact

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

1. Information We Collect

We collect information you provide directly to us, including:

2. How We Use Your Information

We use the information we collect to:

3. Information Sharing

We do not sell your personal information. We may share information with:

4. Data Security

We implement appropriate security measures to protect your personal information. However, no method of transmission over the internet is 100% secure.

5. Your Rights

You have the right to:

6. Cookies

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.

7. Changes to This Policy

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.

8. Contact Us

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()