597 lines
26 KiB
Python
597 lines
26 KiB
Python
"""
|
|
Homepage Seeder
|
|
Seeds the homepage with comprehensive content including images from Unsplash
|
|
"""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
from datetime import datetime, timezone
|
|
|
|
# Add parent directory to path to import modules
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from sqlalchemy.orm import Session
|
|
from src.shared.config.database import SessionLocal, engine
|
|
from src.content.models.page_content import PageContent, PageType
|
|
from src.shared.config.logging_config import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
def get_homepage_data():
|
|
"""Generate comprehensive homepage data with Unsplash images"""
|
|
|
|
# Using Unsplash Source API for images (free, no API key needed)
|
|
# Format: https://source.unsplash.com/{width}x{height}/?{keywords}
|
|
|
|
return {
|
|
'page_type': PageType.HOME,
|
|
'title': 'Luxury Hotel & Resort',
|
|
'subtitle': 'Experience Unparalleled Elegance and Comfort',
|
|
'description': 'Welcome to our world-class luxury hotel where exceptional service meets breathtaking elegance. Discover a sanctuary of sophistication and comfort.',
|
|
'content': '<p>Experience the pinnacle of luxury hospitality at our award-winning hotel. Nestled in a prime location, we offer world-class amenities, exquisite dining, and unparalleled service that creates unforgettable memories.</p>',
|
|
|
|
# SEO Meta Tags
|
|
'meta_title': 'Luxury Hotel & Resort | Premium Accommodation & World-Class Service',
|
|
'meta_description': 'Discover luxury accommodation with world-class amenities, fine dining, and exceptional service. Book your stay at our award-winning hotel today.',
|
|
'meta_keywords': 'luxury hotel, resort, premium accommodation, fine dining, spa, business hotel, vacation, travel',
|
|
'og_title': 'Luxury Hotel & Resort - Experience Unparalleled Elegance',
|
|
'og_description': 'Welcome to our world-class luxury hotel where exceptional service meets breathtaking elegance.',
|
|
'og_image': 'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&h=630&fit=crop',
|
|
'canonical_url': 'https://luxuryhotel.com',
|
|
|
|
# Hero Section
|
|
'hero_title': 'Welcome to Luxury Redefined',
|
|
'hero_subtitle': 'Where Every Moment Becomes a Memory',
|
|
'hero_image': 'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1920&h=1080&fit=crop',
|
|
'hero_video_url': None,
|
|
'hero_video_poster': None,
|
|
|
|
# Story Content
|
|
'story_content': '<p>For over three decades, we have been crafting exceptional experiences for our guests. Our commitment to excellence, attention to detail, and passion for hospitality has made us a destination of choice for discerning travelers worldwide.</p>',
|
|
|
|
# Values Section
|
|
'values': json.dumps([
|
|
{
|
|
'icon': 'heart',
|
|
'title': 'Excellence',
|
|
'description': 'We strive for perfection in every detail, ensuring your experience exceeds expectations.'
|
|
},
|
|
{
|
|
'icon': 'shield',
|
|
'title': 'Trust',
|
|
'description': 'Your comfort and security are our top priorities, backed by years of trusted service.'
|
|
},
|
|
{
|
|
'icon': 'users',
|
|
'title': 'Hospitality',
|
|
'description': 'Our dedicated team is committed to making your stay memorable and delightful.'
|
|
},
|
|
{
|
|
'icon': 'award',
|
|
'title': 'Quality',
|
|
'description': 'We maintain the highest standards in service, amenities, and guest satisfaction.'
|
|
}
|
|
]),
|
|
|
|
# Features Section
|
|
'features_section_title': 'Why Choose Us',
|
|
'features_section_subtitle': 'Discover what makes us the perfect choice for your stay',
|
|
'features': json.dumps([
|
|
{
|
|
'icon': 'wifi',
|
|
'title': 'Free High-Speed WiFi',
|
|
'description': 'Stay connected with complimentary high-speed internet throughout the property.',
|
|
'image': 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'utensils',
|
|
'title': 'Fine Dining',
|
|
'description': 'Savor exquisite cuisine at our award-winning restaurants and bars.',
|
|
'image': 'https://images.unsplash.com/photo-1414235077428-338989a2e8c0?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'spa',
|
|
'title': 'Luxury Spa',
|
|
'description': 'Rejuvenate your mind and body at our world-class spa and wellness center.',
|
|
'image': 'https://images.unsplash.com/photo-1544161515-4ab6ce6db874?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'dumbbell',
|
|
'title': 'Fitness Center',
|
|
'description': 'Maintain your workout routine in our state-of-the-art fitness facility.',
|
|
'image': 'https://images.unsplash.com/photo-1534438327276-14e5300c3a48?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'swimming-pool',
|
|
'title': 'Swimming Pool',
|
|
'description': 'Relax and unwind in our stunning outdoor and indoor pools.',
|
|
'image': 'https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'car',
|
|
'title': 'Valet Parking',
|
|
'description': 'Complimentary valet parking service for all our guests.',
|
|
'image': 'https://images.unsplash.com/photo-1502877338535-766e1452684a?w=800&h=600&fit=crop'
|
|
}
|
|
]),
|
|
|
|
# About Preview Section
|
|
'about_preview_title': 'Our Story',
|
|
'about_preview_subtitle': 'A Legacy of Excellence',
|
|
'about_preview_content': '<p>Since our founding, we have been dedicated to providing exceptional hospitality experiences. Our commitment to excellence, combined with our passion for service, has established us as a leader in the luxury hospitality industry.</p>',
|
|
'about_preview_image': 'https://images.unsplash.com/photo-1520250497591-112f2f40a3f4?w=1200&h=800&fit=crop',
|
|
|
|
# Stats Section
|
|
'stats_section_title': 'Our Achievements',
|
|
'stats_section_subtitle': 'Numbers that speak for themselves',
|
|
'stats': json.dumps([
|
|
{
|
|
'number': '50000+',
|
|
'label': 'Happy Guests',
|
|
'icon': 'users'
|
|
},
|
|
{
|
|
'number': '30+',
|
|
'label': 'Years of Excellence',
|
|
'icon': 'calendar'
|
|
},
|
|
{
|
|
'number': '150+',
|
|
'label': 'Awards Won',
|
|
'icon': 'award'
|
|
},
|
|
{
|
|
'number': '98%',
|
|
'label': 'Guest Satisfaction',
|
|
'icon': 'star'
|
|
}
|
|
]),
|
|
|
|
# Rooms Section
|
|
'rooms_section_title': 'Luxurious Accommodations',
|
|
'rooms_section_subtitle': 'Elegant rooms and suites designed for your comfort',
|
|
'rooms_section_button_text': 'View All Rooms',
|
|
'rooms_section_button_link': '/rooms',
|
|
'rooms_section_enabled': True,
|
|
|
|
# Luxury Services Section
|
|
'luxury_services_section_title': 'Premium Services',
|
|
'luxury_services_section_subtitle': 'Indulge in our exclusive offerings',
|
|
'services_section_button_text': 'Explore Services',
|
|
'services_section_button_link': '/services',
|
|
'services_section_limit': 6,
|
|
'luxury_services': json.dumps([
|
|
{
|
|
'icon': 'concierge',
|
|
'title': '24/7 Concierge',
|
|
'description': 'Our dedicated concierge team is available around the clock to assist with any request.',
|
|
'image': 'https://images.unsplash.com/photo-1556761175-5973dc0f32e7?w=600&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'plane',
|
|
'title': 'Airport Transfer',
|
|
'description': 'Complimentary airport transfer service for a seamless arrival experience.',
|
|
'image': 'https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=600&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'briefcase',
|
|
'title': 'Business Center',
|
|
'description': 'Fully equipped business center with meeting rooms and conference facilities.',
|
|
'image': 'https://images.unsplash.com/photo-1497366216548-37526070297c?w=600&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'wine',
|
|
'title': 'Wine Cellar',
|
|
'description': 'Explore our extensive collection of fine wines from around the world.',
|
|
'image': 'https://images.unsplash.com/photo-1510812431401-41d2bd2722f3?w=600&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'music',
|
|
'title': 'Live Entertainment',
|
|
'description': 'Enjoy live music and entertainment in our elegant lounge areas.',
|
|
'image': 'https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?w=600&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'gift',
|
|
'title': 'Gift Shop',
|
|
'description': 'Browse our curated selection of luxury gifts and souvenirs.',
|
|
'image': 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=600&h=400&fit=crop'
|
|
}
|
|
]),
|
|
|
|
# Luxury Experiences Section
|
|
'luxury_experiences_section_title': 'Unique Experiences',
|
|
'luxury_experiences_section_subtitle': 'Create unforgettable memories with our curated experiences',
|
|
'luxury_experiences': json.dumps([
|
|
{
|
|
'icon': 'sunset',
|
|
'title': 'Sunset Rooftop Dining',
|
|
'description': 'Dine under the stars with panoramic city views and gourmet cuisine.',
|
|
'image': 'https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'compass',
|
|
'title': 'City Tours',
|
|
'description': 'Explore the city with our guided tours showcasing local culture and landmarks.',
|
|
'image': 'https://images.unsplash.com/photo-1488646953014-85cb44e25828?w=800&h=600&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'camera',
|
|
'title': 'Photography Sessions',
|
|
'description': 'Capture your special moments with our professional photography services.',
|
|
'image': 'https://images.unsplash.com/photo-1516035069371-29a1b244cc32?w=800&h=600&fit=crop'
|
|
}
|
|
]),
|
|
|
|
# Amenities Section
|
|
'amenities_section_title': 'World-Class Amenities',
|
|
'amenities_section_subtitle': 'Everything you need for a perfect stay',
|
|
'amenities': json.dumps([
|
|
{
|
|
'icon': 'wifi',
|
|
'title': 'Free WiFi',
|
|
'description': 'High-speed internet access throughout the property'
|
|
},
|
|
{
|
|
'icon': 'tv',
|
|
'title': 'Smart TV',
|
|
'description': 'Streaming services and premium channels in every room'
|
|
},
|
|
{
|
|
'icon': 'coffee',
|
|
'title': 'Coffee Maker',
|
|
'description': 'Premium coffee and tea making facilities'
|
|
},
|
|
{
|
|
'icon': 'snowflake',
|
|
'title': 'Climate Control',
|
|
'description': 'Individual temperature control in all rooms'
|
|
},
|
|
{
|
|
'icon': 'lock',
|
|
'title': 'Safe',
|
|
'description': 'In-room safe for your valuables'
|
|
},
|
|
{
|
|
'icon': 'shirt',
|
|
'title': 'Laundry Service',
|
|
'description': 'Professional laundry and dry cleaning services'
|
|
}
|
|
]),
|
|
|
|
# Testimonials Section
|
|
'testimonials_section_title': 'What Our Guests Say',
|
|
'testimonials_section_subtitle': 'Real experiences from real guests',
|
|
'testimonials': json.dumps([
|
|
{
|
|
'name': 'Sarah Johnson',
|
|
'title': 'Business Traveler',
|
|
'quote': 'The service was exceptional and the rooms were immaculate. This hotel exceeded all my expectations.',
|
|
'rating': 5,
|
|
'image': 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=200&h=200&fit=crop&crop=face'
|
|
},
|
|
{
|
|
'name': 'Michael Chen',
|
|
'title': 'Honeymooner',
|
|
'quote': 'Our honeymoon was made perfect by the attentive staff and beautiful accommodations. Truly unforgettable!',
|
|
'rating': 5,
|
|
'image': 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face'
|
|
},
|
|
{
|
|
'name': 'Emily Rodriguez',
|
|
'title': 'Family Vacation',
|
|
'quote': 'Perfect for families! The kids loved the pool and the staff was so accommodating. We will definitely return.',
|
|
'rating': 5,
|
|
'image': 'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200&h=200&fit=crop&crop=face'
|
|
},
|
|
{
|
|
'name': 'David Thompson',
|
|
'title': 'Luxury Traveler',
|
|
'quote': 'The attention to detail and level of service is unmatched. This is what luxury hospitality should be.',
|
|
'rating': 5,
|
|
'image': 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200&h=200&fit=crop&crop=face'
|
|
}
|
|
]),
|
|
|
|
# Gallery Section
|
|
'gallery_section_title': 'Photo Gallery',
|
|
'gallery_section_subtitle': 'A glimpse into our world of luxury',
|
|
'gallery_images': json.dumps([
|
|
'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1520250497591-112f2f40a3f4?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1542314831-068cd1dbfeeb?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1578683010236-d716f9a3f461?w=1200&h=800&fit=crop'
|
|
]),
|
|
|
|
# Luxury Section
|
|
'luxury_section_title': 'Luxury Redefined',
|
|
'luxury_section_subtitle': 'Experience the epitome of elegance and sophistication',
|
|
'luxury_section_image': 'https://images.unsplash.com/photo-1618773928121-c32242e63f39?w=1400&h=900&fit=crop',
|
|
'luxury_features': json.dumps([
|
|
{
|
|
'icon': 'crown',
|
|
'title': 'Royal Treatment',
|
|
'description': 'Experience service fit for royalty with our personalized attention to every detail.'
|
|
},
|
|
{
|
|
'icon': 'gem',
|
|
'title': 'Premium Quality',
|
|
'description': 'Only the finest materials and furnishings grace our elegant spaces.'
|
|
},
|
|
{
|
|
'icon': 'sparkles',
|
|
'title': 'Exclusive Access',
|
|
'description': 'Enjoy exclusive access to private lounges and premium facilities.'
|
|
}
|
|
]),
|
|
|
|
# Luxury Gallery Section
|
|
'luxury_gallery_section_title': 'Luxury Gallery',
|
|
'luxury_gallery_section_subtitle': 'Discover our world of refined elegance',
|
|
'luxury_gallery': json.dumps([
|
|
'https://images.unsplash.com/photo-1618773928121-c32242e63f39?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1596394516093-501ba68a0ba6?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1631049307264-da0ec9d70304?w=1200&h=800&fit=crop',
|
|
'https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1200&h=800&fit=crop'
|
|
]),
|
|
|
|
# Luxury Testimonials Section
|
|
'luxury_testimonials_section_title': 'Guest Experiences',
|
|
'luxury_testimonials_section_subtitle': 'Stories from our valued guests',
|
|
'luxury_testimonials': json.dumps([
|
|
{
|
|
'name': 'James Wilson',
|
|
'title': 'VIP Guest',
|
|
'quote': 'The level of luxury and attention to detail is simply extraordinary. This is hospitality at its finest.',
|
|
'image': 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=200&h=200&fit=crop&crop=face'
|
|
},
|
|
{
|
|
'name': 'Maria Garcia',
|
|
'title': 'Celebrity Guest',
|
|
'quote': 'Privacy, elegance, and impeccable service. This hotel understands true luxury.',
|
|
'image': 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=200&h=200&fit=crop&crop=face'
|
|
}
|
|
]),
|
|
|
|
# Awards Section
|
|
'awards_section_title': 'Awards & Recognition',
|
|
'awards_section_subtitle': 'Recognized for excellence in hospitality',
|
|
'awards': json.dumps([
|
|
{
|
|
'icon': 'trophy',
|
|
'title': 'Best Luxury Hotel 2023',
|
|
'description': 'Awarded by International Hospitality Association',
|
|
'year': '2023',
|
|
'image': 'https://images.unsplash.com/photo-1606761568499-6d2451b23c66?w=400&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'star',
|
|
'title': '5-Star Rating',
|
|
'description': 'Consistently rated 5 stars by leading travel organizations',
|
|
'year': '2023',
|
|
'image': 'https://images.unsplash.com/photo-1519389950473-47ba0277781c?w=400&h=400&fit=crop'
|
|
},
|
|
{
|
|
'icon': 'award',
|
|
'title': 'Excellence in Service',
|
|
'description': 'Recognized for outstanding customer service and guest satisfaction',
|
|
'year': '2022',
|
|
'image': 'https://images.unsplash.com/photo-1579621970563-ebec7560ff3e?w=400&h=400&fit=crop'
|
|
}
|
|
]),
|
|
|
|
# Partners Section
|
|
'partners_section_title': 'Our Partners',
|
|
'partners_section_subtitle': 'Trusted by leading brands and organizations',
|
|
'partners': json.dumps([
|
|
{
|
|
'name': 'Travel Partner',
|
|
'logo': 'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=200&h=100&fit=crop',
|
|
'url': '#'
|
|
},
|
|
{
|
|
'name': 'Luxury Brand',
|
|
'logo': 'https://images.unsplash.com/photo-1520250497591-112f2f40a3f4?w=200&h=100&fit=crop',
|
|
'url': '#'
|
|
},
|
|
{
|
|
'name': 'Hospitality Group',
|
|
'logo': 'https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=200&h=100&fit=crop',
|
|
'url': '#'
|
|
}
|
|
]),
|
|
|
|
# CTA Section
|
|
'cta_title': 'Ready to Experience Luxury?',
|
|
'cta_subtitle': 'Book your stay today and discover why we are the preferred choice for discerning travelers',
|
|
'cta_button_text': 'Book Now',
|
|
'cta_button_link': '/book',
|
|
'cta_image': 'https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1400&h=700&fit=crop',
|
|
|
|
# Newsletter Section
|
|
'newsletter_section_title': 'Stay Connected',
|
|
'newsletter_section_subtitle': 'Subscribe to our newsletter for exclusive offers and updates',
|
|
'newsletter_placeholder': 'Enter your email address',
|
|
'newsletter_button_text': 'Subscribe',
|
|
'newsletter_enabled': True,
|
|
|
|
# Trust Badges Section
|
|
'trust_badges_section_title': 'Why Trust Us',
|
|
'trust_badges_section_subtitle': 'Your peace of mind is our priority',
|
|
'trust_badges_enabled': True,
|
|
'trust_badges': json.dumps([
|
|
{
|
|
'icon': 'shield-check',
|
|
'title': 'Secure Booking',
|
|
'description': 'Your data and payments are protected with industry-leading security'
|
|
},
|
|
{
|
|
'icon': 'clock',
|
|
'title': '24/7 Support',
|
|
'description': 'Round-the-clock customer support for all your needs'
|
|
},
|
|
{
|
|
'icon': 'undo',
|
|
'title': 'Flexible Cancellation',
|
|
'description': 'Free cancellation up to 24 hours before check-in'
|
|
},
|
|
{
|
|
'icon': 'check-circle',
|
|
'title': 'Best Price Guarantee',
|
|
'description': 'We guarantee the best rates for your stay'
|
|
}
|
|
]),
|
|
|
|
# Promotions Section
|
|
'promotions_section_title': 'Special Offers',
|
|
'promotions_section_subtitle': 'Exclusive deals and packages for our guests',
|
|
'promotions_enabled': True,
|
|
'promotions': json.dumps([
|
|
{
|
|
'title': 'Early Bird Special',
|
|
'description': 'Book 30 days in advance and save 20%',
|
|
'discount': '20% OFF',
|
|
'image': 'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800&h=600&fit=crop',
|
|
'link': '/promotions/early-bird'
|
|
},
|
|
{
|
|
'title': 'Weekend Getaway',
|
|
'description': 'Perfect weekend escape with complimentary breakfast',
|
|
'discount': '15% OFF',
|
|
'image': 'https://images.unsplash.com/photo-1520250497591-112f2f40a3f4?w=800&h=600&fit=crop',
|
|
'link': '/promotions/weekend'
|
|
},
|
|
{
|
|
'title': 'Honeymoon Package',
|
|
'description': 'Romantic getaway with special amenities and services',
|
|
'discount': '25% OFF',
|
|
'image': 'https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800&h=600&fit=crop',
|
|
'link': '/promotions/honeymoon'
|
|
}
|
|
]),
|
|
|
|
# Blog Section
|
|
'blog_section_title': 'Latest News & Updates',
|
|
'blog_section_subtitle': 'Stay informed with our latest articles and hotel news',
|
|
'blog_posts_limit': 3,
|
|
'blog_enabled': True,
|
|
|
|
# Sections Enabled
|
|
'sections_enabled': json.dumps({
|
|
'hero': True,
|
|
'features': True,
|
|
'about_preview': True,
|
|
'stats': True,
|
|
'rooms': True,
|
|
'services': True,
|
|
'experiences': True,
|
|
'amenities': True,
|
|
'testimonials': True,
|
|
'gallery': True,
|
|
'luxury': True,
|
|
'awards': True,
|
|
'partners': True,
|
|
'cta': True,
|
|
'newsletter': True,
|
|
'trust_badges': True,
|
|
'promotions': True,
|
|
'blog': True
|
|
}),
|
|
|
|
# Badges
|
|
'badges': json.dumps([
|
|
{
|
|
'text': '5-Star Rated',
|
|
'icon': 'star'
|
|
},
|
|
{
|
|
'text': 'Award Winning',
|
|
'icon': 'award'
|
|
},
|
|
{
|
|
'text': 'Eco-Friendly',
|
|
'icon': 'leaf'
|
|
}
|
|
]),
|
|
|
|
# Social Links
|
|
'social_links': json.dumps({
|
|
'facebook': 'https://facebook.com/luxuryhotel',
|
|
'twitter': 'https://twitter.com/luxuryhotel',
|
|
'instagram': 'https://instagram.com/luxuryhotel',
|
|
'linkedin': 'https://linkedin.com/company/luxuryhotel',
|
|
'youtube': 'https://youtube.com/luxuryhotel'
|
|
}),
|
|
|
|
# Contact Info
|
|
'contact_info': json.dumps({
|
|
'phone': '+1 (555) 123-4567',
|
|
'email': 'info@luxuryhotel.com',
|
|
'address': '123 Luxury Avenue, Premium City, PC 12345'
|
|
}),
|
|
|
|
# Active Status
|
|
'is_active': True,
|
|
'created_at': datetime.now(timezone.utc),
|
|
'updated_at': datetime.now(timezone.utc)
|
|
}
|
|
|
|
|
|
def seed_homepage(db: Session):
|
|
"""Seed the homepage content"""
|
|
try:
|
|
# Check if homepage already exists
|
|
existing = db.query(PageContent).filter(PageContent.page_type == PageType.HOME).first()
|
|
|
|
if existing:
|
|
logger.info('Homepage content already exists. Updating...')
|
|
# Update existing content
|
|
data = get_homepage_data()
|
|
for key, value in data.items():
|
|
if key != 'page_type': # Don't update page_type
|
|
setattr(existing, key, value)
|
|
existing.updated_at = datetime.now(timezone.utc)
|
|
db.commit()
|
|
logger.info('Homepage content updated successfully!')
|
|
return existing
|
|
else:
|
|
logger.info('Creating new homepage content...')
|
|
# Create new content
|
|
data = get_homepage_data()
|
|
homepage = PageContent(**data)
|
|
db.add(homepage)
|
|
db.commit()
|
|
db.refresh(homepage)
|
|
logger.info('Homepage content created successfully!')
|
|
return homepage
|
|
|
|
except Exception as e:
|
|
logger.error(f'Error seeding homepage: {str(e)}', exc_info=True)
|
|
db.rollback()
|
|
raise
|
|
|
|
|
|
def main():
|
|
"""Main function to run the seeder"""
|
|
logger.info('Starting homepage seeder...')
|
|
|
|
db = SessionLocal()
|
|
try:
|
|
homepage = seed_homepage(db)
|
|
logger.info(f'Homepage seeder completed successfully! ID: {homepage.id}')
|
|
except Exception as e:
|
|
logger.error(f'Failed to seed homepage: {str(e)}', exc_info=True)
|
|
sys.exit(1)
|
|
finally:
|
|
db.close()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|