updates
This commit is contained in:
167
Backend/seeders/contact_seeder.py
Normal file
167
Backend/seeders/contact_seeder.py
Normal file
@@ -0,0 +1,167 @@
|
||||
"""
|
||||
Contact Page Seeder
|
||||
Seeds the database with comprehensive contact page content
|
||||
All images are from Unsplash (free stock photos)
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timezone
|
||||
|
||||
# Add parent directory to path to allow importing from src
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from src.shared.config.database import SessionLocal
|
||||
from src.shared.config.logging_config import get_logger
|
||||
from src.content.models.page_content import PageContent, PageType
|
||||
|
||||
# Import all models to ensure relationships are loaded
|
||||
from src.models import *
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def get_contact_page_data():
|
||||
"""Generate comprehensive contact page data with Unsplash images"""
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
return {
|
||||
'page_type': PageType.CONTACT,
|
||||
'title': 'Contact Us',
|
||||
'subtitle': 'We\'re Here to Help - Get in Touch',
|
||||
'description': 'Have questions or need assistance? Our friendly team is available 24/7 to help with reservations, inquiries, and special requests. Reach out to us through any of the methods below.',
|
||||
'content': '<p>We value your feedback and are here to assist you with any questions or requests. Whether you\'re planning a stay, have a question about our services, or need assistance during your visit, our team is ready to help.</p>',
|
||||
'meta_title': 'Contact Us | Luxury Hotel & Resort - Get in Touch',
|
||||
'meta_description': 'Contact our luxury hotel for reservations, inquiries, or assistance. Our friendly team is available 24/7. Phone, email, and location information.',
|
||||
'meta_keywords': 'contact us, hotel contact, reservations, customer service, hotel phone number, hotel email',
|
||||
'og_title': 'Contact Us - Luxury Hotel & Resort',
|
||||
'og_description': 'Have questions or need assistance? Our friendly team is available 24/7 to help with reservations, inquiries, and special requests.',
|
||||
'og_image': 'https://images.unsplash.com/photo-1556761175-5973dc0f32e7?w=1200&h=630&fit=crop',
|
||||
'canonical_url': 'https://luxuryhotel.com/contact',
|
||||
'hero_title': 'Get in Touch',
|
||||
'hero_subtitle': 'We\'re Here to Help You',
|
||||
'hero_image': 'https://images.unsplash.com/photo-1556761175-5973dc0f32e7?w=1920&h=1080&fit=crop',
|
||||
'hero_video_url': None,
|
||||
'hero_video_poster': None,
|
||||
'contact_info': json.dumps({
|
||||
'phone': '+1 (555) 123-4567',
|
||||
'toll_free': '+1 (800) 123-4567',
|
||||
'email': 'info@luxuryhotel.com',
|
||||
'reservations_email': 'reservations@luxuryhotel.com',
|
||||
'address': '123 Luxury Avenue, Premium City, PC 12345',
|
||||
'address_line2': 'United States',
|
||||
'business_hours': {
|
||||
'front_desk': '24/7',
|
||||
'concierge': '24/7',
|
||||
'reservations': 'Monday - Sunday: 8:00 AM - 10:00 PM',
|
||||
'restaurant': 'Breakfast: 7:00 AM - 11:00 AM, Lunch: 12:00 PM - 3:00 PM, Dinner: 6:00 PM - 11:00 PM',
|
||||
'spa': 'Monday - Sunday: 9:00 AM - 9:00 PM'
|
||||
}
|
||||
}),
|
||||
'map_url': 'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3022.184132576!2d-73.98811768459418!3d40.75889597932681!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c25855c6480299%3A0x55194ec5a1ae072e!2sTimes%20Square!5e0!3m2!1sen!2sus!4v1234567890123!5m2!1sen!2sus',
|
||||
'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',
|
||||
'pinterest': 'https://pinterest.com/luxuryhotel'
|
||||
}),
|
||||
'testimonials': json.dumps([
|
||||
{
|
||||
'name': 'Sarah Johnson',
|
||||
'title': 'Guest',
|
||||
'quote': 'The customer service team was incredibly helpful and responsive. They answered all my questions and made my booking process seamless.',
|
||||
'rating': 5,
|
||||
'image': 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=200&h=200&fit=crop&crop=face'
|
||||
},
|
||||
{
|
||||
'name': 'Michael Chen',
|
||||
'title': 'Business Traveler',
|
||||
'quote': 'The concierge team went above and beyond to help with my business needs. Their attention to detail and professionalism is outstanding.',
|
||||
'rating': 5,
|
||||
'image': 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face'
|
||||
}
|
||||
]),
|
||||
'testimonials_section_title': 'What Our Guests Say About Our Service',
|
||||
'testimonials_section_subtitle': 'Real feedback from our valued guests',
|
||||
'features': json.dumps([
|
||||
{
|
||||
'icon': 'phone',
|
||||
'title': '24/7 Support',
|
||||
'description': 'Our team is available around the clock to assist you with any questions or requests.'
|
||||
},
|
||||
{
|
||||
'icon': 'clock',
|
||||
'title': 'Quick Response',
|
||||
'description': 'We respond to all inquiries within 24 hours, often much sooner.'
|
||||
},
|
||||
{
|
||||
'icon': 'users',
|
||||
'title': 'Expert Team',
|
||||
'description': 'Our knowledgeable staff is trained to provide exceptional service and assistance.'
|
||||
},
|
||||
{
|
||||
'icon': 'globe',
|
||||
'title': 'Multiple Languages',
|
||||
'description': 'We speak your language. Our team is fluent in multiple languages to serve international guests.'
|
||||
}
|
||||
]),
|
||||
'features_section_title': 'Why Contact Us',
|
||||
'features_section_subtitle': 'We\'re committed to providing exceptional service',
|
||||
'gallery_images': json.dumps([
|
||||
'https://images.unsplash.com/photo-1556761175-5973dc0f32e7?w=1200&h=800&fit=crop',
|
||||
'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'
|
||||
]),
|
||||
'gallery_section_title': 'Visit Our Hotel',
|
||||
'gallery_section_subtitle': 'Experience our luxury facilities',
|
||||
'is_active': True,
|
||||
'created_at': now,
|
||||
'updated_at': now
|
||||
}
|
||||
|
||||
|
||||
def seed_contact_page(db: Session):
|
||||
"""Seed contact page content into the database"""
|
||||
try:
|
||||
contact_data = get_contact_page_data()
|
||||
|
||||
# Check if contact page content already exists
|
||||
existing_content = db.query(PageContent).filter(PageContent.page_type == PageType.CONTACT).first()
|
||||
|
||||
if existing_content:
|
||||
logger.info('Updating existing contact page content...')
|
||||
for key, value in contact_data.items():
|
||||
if key not in ['id', 'page_type', 'created_at']: # Don't update primary key or creation date
|
||||
setattr(existing_content, key, value)
|
||||
existing_content.updated_at = datetime.now(timezone.utc)
|
||||
else:
|
||||
logger.info('Creating new contact page content...')
|
||||
contact_page = PageContent(**contact_data)
|
||||
db.add(contact_page)
|
||||
|
||||
db.commit()
|
||||
logger.info('Contact page content seeded successfully!')
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
logger.error(f'Error seeding contact page: {str(e)}', exc_info=True)
|
||||
raise
|
||||
|
||||
|
||||
def main():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
seed_contact_page(db)
|
||||
except Exception as e:
|
||||
logger.error(f'Failed to seed contact page: {str(e)}', exc_info=True)
|
||||
sys.exit(1)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user