Files
Hotel-Booking/Backend/seed_luxury_content.py
Iliyan Angelov a38ab4fa82 updates
2025-11-20 21:06:30 +02:00

124 lines
4.8 KiB
Python

"""
Seed script to populate initial luxury content for the homepage.
Run this script to add default luxury content to the page_content table.
"""
import sys
import os
import json
# Add the src directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from sqlalchemy.orm import Session
from src.config.database import SessionLocal, engine
from src.models.page_content import PageContent
from src.models.user import User
def seed_luxury_content():
"""Seed luxury content for the homepage"""
db: Session = SessionLocal()
try:
# Check if home page content already exists
existing = db.query(PageContent).filter(PageContent.page_type == 'home').first()
luxury_features = [
{
"icon": "Sparkles",
"title": "Premium Amenities",
"description": "World-class facilities designed for your comfort and relaxation"
},
{
"icon": "Crown",
"title": "Royal Service",
"description": "Dedicated concierge service available 24/7 for all your needs"
},
{
"icon": "Award",
"title": "Award-Winning",
"description": "Recognized for excellence in hospitality and guest satisfaction"
},
{
"icon": "Shield",
"title": "Secure & Private",
"description": "Your privacy and security are our top priorities"
},
{
"icon": "Heart",
"title": "Personalized Care",
"description": "Tailored experiences crafted just for you"
},
{
"icon": "Gem",
"title": "Luxury Design",
"description": "Elegantly designed spaces with attention to every detail"
}
]
luxury_testimonials = [
{
"name": "Sarah Johnson",
"title": "Business Executive",
"quote": "An absolutely stunning experience. The attention to detail and level of service exceeded all expectations.",
"image": ""
},
{
"name": "Michael Chen",
"title": "Travel Enthusiast",
"quote": "The epitome of luxury. Every moment was perfect, from check-in to check-out.",
"image": ""
},
{
"name": "Emma Williams",
"title": "Luxury Traveler",
"quote": "This hotel redefines what luxury means. I will definitely return.",
"image": ""
}
]
if existing:
# Update existing content
existing.luxury_section_title = "Experience Unparalleled Luxury"
existing.luxury_section_subtitle = "Where elegance meets comfort in every detail"
existing.luxury_section_image = None
existing.luxury_features = json.dumps(luxury_features)
existing.luxury_gallery = json.dumps([])
existing.luxury_testimonials = json.dumps(luxury_testimonials)
existing.about_preview_title = "About Our Luxury Hotel"
existing.about_preview_content = "Discover a world of refined elegance and exceptional service. Our hotel combines timeless luxury with modern amenities to create an unforgettable experience."
existing.about_preview_image = None
print("✓ Updated existing home page content with luxury sections")
else:
# Create new content
new_content = PageContent(
page_type='home',
luxury_section_title="Experience Unparalleled Luxury",
luxury_section_subtitle="Where elegance meets comfort in every detail",
luxury_section_image=None,
luxury_features=json.dumps(luxury_features),
luxury_gallery=json.dumps([]),
luxury_testimonials=json.dumps(luxury_testimonials),
about_preview_title="About Our Luxury Hotel",
about_preview_content="Discover a world of refined elegance and exceptional service. Our hotel combines timeless luxury with modern amenities to create an unforgettable experience.",
about_preview_image=None,
is_active=True
)
db.add(new_content)
print("✓ Created new home page content with luxury sections")
db.commit()
print("✓ Luxury content seeded successfully!")
except Exception as e:
db.rollback()
print(f"✗ Error seeding luxury content: {e}")
raise
finally:
db.close()
if __name__ == "__main__":
print("Seeding luxury content...")
seed_luxury_content()
print("Done!")