""" Cancellation Policy Page Seeder Seeds the database with comprehensive cancellation policy content """ 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_cancellation_page_data(): """Generate comprehensive cancellation policy page data""" now = datetime.now(timezone.utc) return { 'page_type': PageType.CANCELLATION, 'title': 'Cancellation Policy', 'subtitle': 'Reservation Cancellation Terms and Conditions', 'description': 'Learn about our cancellation policy, including cancellation deadlines, fees, and procedures for different rate types.', 'content': """

1. Overview

This Cancellation Policy outlines the terms and conditions for cancelling reservations at Luxury Hotel & Resort. Cancellation terms vary by rate type and are clearly stated at the time of booking. Please review this policy carefully before making a reservation.

2. Standard Cancellation Policy

2.1 Flexible Rate

For reservations made with our Flexible Rate:

2.2 Non-Refundable Rate

For reservations made with our Non-Refundable Rate:

2.3 Advance Purchase Rate

For Advance Purchase rates:

3. Special Packages and Promotions

Cancellation terms for special packages, promotions, and seasonal offers may differ from standard rates. Specific cancellation terms will be clearly stated at the time of booking and in your confirmation email.

4. Group Bookings

For group bookings (typically 10 or more rooms):

5. Event and Meeting Bookings

Cancellation policies for event and meeting space bookings are detailed in your event contract. Generally:

6. How to Cancel

6.1 Online Cancellation

You can cancel your reservation online through:

6.2 Phone Cancellation

Call our reservations team:

6.3 Email Cancellation

Send an email to:

7. Cancellation Confirmation

Upon successful cancellation, you will receive a cancellation confirmation email. Please retain this confirmation for your records. If you do not receive a confirmation, please contact us to verify that your cancellation was processed.

8. Refunds

Refunds for eligible cancellations will be processed to the original payment method within 5-10 business days. The time it takes for the refund to appear in your account depends on your financial institution. For more information, please refer to our Refund Policy.

9. Modifications vs. Cancellations

9.1 Date Changes

Modifying your reservation dates may be treated as a cancellation and rebooking, subject to availability and current rates. Please contact us to discuss modification options.

9.2 Room Type Changes

Changes to room type are subject to availability and rate differences. Additional charges may apply if the new room type has a higher rate.

10. Force Majeure

In cases of force majeure events (natural disasters, pandemics, government restrictions, travel bans, etc.), we will work with you to provide flexible cancellation options, including:

Each situation is evaluated individually. Please contact us as soon as possible if you are affected by a force majeure event.

11. Third-Party Bookings

If you made your reservation through a third-party booking site (such as Expedia, Booking.com, etc.), you must cancel through that third party according to their cancellation policies. We cannot directly cancel third-party bookings.

12. No-Show Policy

If you do not arrive on your scheduled check-in date and have not cancelled your reservation:

13. Early Departure

If you check out earlier than your scheduled departure date:

14. Special Circumstances

We understand that unexpected circumstances may arise. In cases of medical emergencies, family emergencies, or other extenuating circumstances, please contact us immediately. We will review your situation and may offer flexible cancellation options on a case-by-case basis.

15. Contact Information

For cancellation requests or questions about our cancellation policy, please contact us:

16. Policy Updates

We reserve the right to update this Cancellation Policy at any time. Changes will be posted on this page with an updated "Last Updated" date. The cancellation terms that apply to your reservation are those in effect at the time you made your booking.

Last Updated: {}

""".format(now.strftime('%B %d, %Y')), 'meta_title': 'Cancellation Policy | Luxury Hotel & Resort', 'meta_description': 'Learn about our cancellation policy, including cancellation deadlines, fees, and procedures for different rate types.', 'meta_keywords': 'cancellation policy, hotel cancellation, booking cancellation, cancel reservation, cancellation terms', 'og_title': 'Cancellation Policy - Luxury Hotel & Resort', 'og_description': 'Reservation cancellation terms and conditions. Learn how to cancel your booking and applicable fees.', 'og_image': 'https://images.unsplash.com/photo-1556761175-5973dc0f32e7?w=1200&h=630&fit=crop', 'canonical_url': 'https://luxuryhotel.com/cancellation', 'is_active': True, 'created_at': now, 'updated_at': now } def seed_cancellation_page(db: Session): """Seed cancellation policy page content into the database""" try: cancellation_data = get_cancellation_page_data() # Check if cancellation page content already exists existing_content = db.query(PageContent).filter(PageContent.page_type == PageType.CANCELLATION).first() if existing_content: logger.info('Updating existing cancellation policy page content...') for key, value in cancellation_data.items(): if key not in ['id', 'page_type', 'created_at']: setattr(existing_content, key, value) existing_content.updated_at = datetime.now(timezone.utc) else: logger.info('Creating new cancellation policy page content...') cancellation_page = PageContent(**cancellation_data) db.add(cancellation_page) db.commit() logger.info('Cancellation policy page content seeded successfully!') except Exception as e: db.rollback() logger.error(f'Error seeding cancellation policy page: {str(e)}', exc_info=True) raise def main(): db = SessionLocal() try: seed_cancellation_page(db) except Exception as e: logger.error(f'Failed to seed cancellation policy page: {str(e)}', exc_info=True) sys.exit(1) finally: db.close() if __name__ == '__main__': main()