updates
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
"""add_section_title_fields_to_page_content
|
||||
|
||||
Revision ID: 1444eb61188e
|
||||
Revises: ff515d77abbe
|
||||
Create Date: 2025-11-20 15:51:29.671843
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1444eb61188e'
|
||||
down_revision = 'ff515d77abbe'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('bookings_room_id', table_name='bookings')
|
||||
op.drop_index('bookings_status', table_name='bookings')
|
||||
op.drop_index('bookings_user_id', table_name='bookings')
|
||||
op.drop_index('ix_bookings_promotion_code', table_name='bookings')
|
||||
op.create_index(op.f('ix_bookings_booking_number'), 'bookings', ['booking_number'], unique=True)
|
||||
op.create_index(op.f('ix_bookings_id'), 'bookings', ['id'], unique=False)
|
||||
op.drop_constraint('bookings_ibfk_1', 'bookings', type_='foreignkey')
|
||||
op.drop_constraint('bookings_ibfk_2', 'bookings', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'bookings', 'rooms', ['room_id'], ['id'])
|
||||
op.create_foreign_key(None, 'bookings', 'users', ['user_id'], ['id'])
|
||||
op.drop_index('checkin_checkout_booking_id', table_name='checkin_checkout')
|
||||
op.create_index(op.f('ix_checkin_checkout_id'), 'checkin_checkout', ['id'], unique=False)
|
||||
op.create_unique_constraint(None, 'checkin_checkout', ['booking_id'])
|
||||
op.drop_constraint('checkin_checkout_ibfk_1', 'checkin_checkout', type_='foreignkey')
|
||||
op.drop_constraint('checkin_checkout_ibfk_2', 'checkin_checkout', type_='foreignkey')
|
||||
op.drop_constraint('checkin_checkout_ibfk_3', 'checkin_checkout', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'checkin_checkout', 'users', ['checkin_by'], ['id'])
|
||||
op.create_foreign_key(None, 'checkin_checkout', 'bookings', ['booking_id'], ['id'])
|
||||
op.create_foreign_key(None, 'checkin_checkout', 'users', ['checkout_by'], ['id'])
|
||||
op.drop_index('favorites_room_id', table_name='favorites')
|
||||
op.drop_index('favorites_user_id', table_name='favorites')
|
||||
op.drop_index('unique_user_room_favorite', table_name='favorites')
|
||||
op.create_index(op.f('ix_favorites_id'), 'favorites', ['id'], unique=False)
|
||||
op.drop_constraint('favorites_ibfk_1', 'favorites', type_='foreignkey')
|
||||
op.drop_constraint('favorites_ibfk_2', 'favorites', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'favorites', 'rooms', ['room_id'], ['id'])
|
||||
op.create_foreign_key(None, 'favorites', 'users', ['user_id'], ['id'])
|
||||
op.add_column('page_contents', sa.Column('luxury_gallery_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_gallery_section_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_testimonials_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_testimonials_section_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_services_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_services_section_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_experiences_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_experiences_section_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('awards_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('awards_section_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('partners_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('partners_section_subtitle', sa.Text(), nullable=True))
|
||||
op.alter_column('password_reset_tokens', 'used',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
nullable=False,
|
||||
existing_server_default=sa.text("'0'"))
|
||||
op.drop_index('password_reset_tokens_token', table_name='password_reset_tokens')
|
||||
op.drop_index('password_reset_tokens_user_id', table_name='password_reset_tokens')
|
||||
op.drop_index('token', table_name='password_reset_tokens')
|
||||
op.create_index(op.f('ix_password_reset_tokens_id'), 'password_reset_tokens', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_password_reset_tokens_token'), 'password_reset_tokens', ['token'], unique=True)
|
||||
op.drop_constraint('password_reset_tokens_ibfk_1', 'password_reset_tokens', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'password_reset_tokens', 'users', ['user_id'], ['id'])
|
||||
op.alter_column('payments', 'deposit_percentage',
|
||||
existing_type=mysql.INTEGER(),
|
||||
comment=None,
|
||||
existing_comment='Percentage of deposit (e.g., 20, 30, 50)',
|
||||
existing_nullable=True)
|
||||
op.drop_index('payments_booking_id', table_name='payments')
|
||||
op.drop_index('payments_payment_status', table_name='payments')
|
||||
op.create_index(op.f('ix_payments_id'), 'payments', ['id'], unique=False)
|
||||
op.drop_constraint('payments_ibfk_1', 'payments', type_='foreignkey')
|
||||
op.drop_constraint('payments_related_payment_id_foreign_idx', 'payments', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'payments', 'payments', ['related_payment_id'], ['id'])
|
||||
op.create_foreign_key(None, 'payments', 'bookings', ['booking_id'], ['id'])
|
||||
op.drop_index('code', table_name='promotions')
|
||||
op.drop_index('promotions_code', table_name='promotions')
|
||||
op.drop_index('promotions_is_active', table_name='promotions')
|
||||
op.create_index(op.f('ix_promotions_code'), 'promotions', ['code'], unique=True)
|
||||
op.create_index(op.f('ix_promotions_id'), 'promotions', ['id'], unique=False)
|
||||
op.drop_index('refresh_tokens_token', table_name='refresh_tokens')
|
||||
op.drop_index('refresh_tokens_user_id', table_name='refresh_tokens')
|
||||
op.drop_index('token', table_name='refresh_tokens')
|
||||
op.create_index(op.f('ix_refresh_tokens_id'), 'refresh_tokens', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_refresh_tokens_token'), 'refresh_tokens', ['token'], unique=True)
|
||||
op.drop_constraint('refresh_tokens_ibfk_1', 'refresh_tokens', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'refresh_tokens', 'users', ['user_id'], ['id'])
|
||||
op.drop_index('reviews_room_id', table_name='reviews')
|
||||
op.drop_index('reviews_status', table_name='reviews')
|
||||
op.drop_index('reviews_user_id', table_name='reviews')
|
||||
op.create_index(op.f('ix_reviews_id'), 'reviews', ['id'], unique=False)
|
||||
op.drop_constraint('reviews_ibfk_2', 'reviews', type_='foreignkey')
|
||||
op.drop_constraint('reviews_ibfk_1', 'reviews', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'reviews', 'users', ['user_id'], ['id'])
|
||||
op.create_foreign_key(None, 'reviews', 'rooms', ['room_id'], ['id'])
|
||||
op.drop_index('name', table_name='roles')
|
||||
op.create_index(op.f('ix_roles_id'), 'roles', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_roles_name'), 'roles', ['name'], unique=True)
|
||||
op.create_index(op.f('ix_room_types_id'), 'room_types', ['id'], unique=False)
|
||||
op.drop_index('room_number', table_name='rooms')
|
||||
op.drop_index('rooms_featured', table_name='rooms')
|
||||
op.drop_index('rooms_room_type_id', table_name='rooms')
|
||||
op.drop_index('rooms_status', table_name='rooms')
|
||||
op.create_index(op.f('ix_rooms_id'), 'rooms', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_rooms_room_number'), 'rooms', ['room_number'], unique=True)
|
||||
op.drop_constraint('rooms_ibfk_1', 'rooms', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'rooms', 'room_types', ['room_type_id'], ['id'])
|
||||
op.drop_index('service_usages_booking_id', table_name='service_usages')
|
||||
op.drop_index('service_usages_service_id', table_name='service_usages')
|
||||
op.create_index(op.f('ix_service_usages_id'), 'service_usages', ['id'], unique=False)
|
||||
op.drop_constraint('service_usages_ibfk_2', 'service_usages', type_='foreignkey')
|
||||
op.drop_constraint('service_usages_ibfk_1', 'service_usages', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'service_usages', 'bookings', ['booking_id'], ['id'])
|
||||
op.create_foreign_key(None, 'service_usages', 'services', ['service_id'], ['id'])
|
||||
op.drop_index('services_category', table_name='services')
|
||||
op.create_index(op.f('ix_services_id'), 'services', ['id'], unique=False)
|
||||
op.drop_index('email', table_name='users')
|
||||
op.drop_index('users_email', table_name='users')
|
||||
op.drop_index('users_role_id', table_name='users')
|
||||
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
|
||||
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
|
||||
op.drop_constraint('users_ibfk_1', 'users', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'users', 'roles', ['role_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'users', type_='foreignkey')
|
||||
op.create_foreign_key('users_ibfk_1', 'users', 'roles', ['role_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.drop_index(op.f('ix_users_id'), table_name='users')
|
||||
op.drop_index(op.f('ix_users_email'), table_name='users')
|
||||
op.create_index('users_role_id', 'users', ['role_id'], unique=False)
|
||||
op.create_index('users_email', 'users', ['email'], unique=False)
|
||||
op.create_index('email', 'users', ['email'], unique=False)
|
||||
op.drop_index(op.f('ix_services_id'), table_name='services')
|
||||
op.create_index('services_category', 'services', ['category'], unique=False)
|
||||
op.drop_constraint(None, 'service_usages', type_='foreignkey')
|
||||
op.drop_constraint(None, 'service_usages', type_='foreignkey')
|
||||
op.create_foreign_key('service_usages_ibfk_1', 'service_usages', 'bookings', ['booking_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.create_foreign_key('service_usages_ibfk_2', 'service_usages', 'services', ['service_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.drop_index(op.f('ix_service_usages_id'), table_name='service_usages')
|
||||
op.create_index('service_usages_service_id', 'service_usages', ['service_id'], unique=False)
|
||||
op.create_index('service_usages_booking_id', 'service_usages', ['booking_id'], unique=False)
|
||||
op.drop_constraint(None, 'rooms', type_='foreignkey')
|
||||
op.create_foreign_key('rooms_ibfk_1', 'rooms', 'room_types', ['room_type_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.drop_index(op.f('ix_rooms_room_number'), table_name='rooms')
|
||||
op.drop_index(op.f('ix_rooms_id'), table_name='rooms')
|
||||
op.create_index('rooms_status', 'rooms', ['status'], unique=False)
|
||||
op.create_index('rooms_room_type_id', 'rooms', ['room_type_id'], unique=False)
|
||||
op.create_index('rooms_featured', 'rooms', ['featured'], unique=False)
|
||||
op.create_index('room_number', 'rooms', ['room_number'], unique=False)
|
||||
op.drop_index(op.f('ix_room_types_id'), table_name='room_types')
|
||||
op.drop_index(op.f('ix_roles_name'), table_name='roles')
|
||||
op.drop_index(op.f('ix_roles_id'), table_name='roles')
|
||||
op.create_index('name', 'roles', ['name'], unique=False)
|
||||
op.drop_constraint(None, 'reviews', type_='foreignkey')
|
||||
op.drop_constraint(None, 'reviews', type_='foreignkey')
|
||||
op.create_foreign_key('reviews_ibfk_1', 'reviews', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
|
||||
op.create_foreign_key('reviews_ibfk_2', 'reviews', 'rooms', ['room_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
|
||||
op.drop_index(op.f('ix_reviews_id'), table_name='reviews')
|
||||
op.create_index('reviews_user_id', 'reviews', ['user_id'], unique=False)
|
||||
op.create_index('reviews_status', 'reviews', ['status'], unique=False)
|
||||
op.create_index('reviews_room_id', 'reviews', ['room_id'], unique=False)
|
||||
op.drop_constraint(None, 'refresh_tokens', type_='foreignkey')
|
||||
op.create_foreign_key('refresh_tokens_ibfk_1', 'refresh_tokens', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
|
||||
op.drop_index(op.f('ix_refresh_tokens_token'), table_name='refresh_tokens')
|
||||
op.drop_index(op.f('ix_refresh_tokens_id'), table_name='refresh_tokens')
|
||||
op.create_index('token', 'refresh_tokens', ['token'], unique=False)
|
||||
op.create_index('refresh_tokens_user_id', 'refresh_tokens', ['user_id'], unique=False)
|
||||
op.create_index('refresh_tokens_token', 'refresh_tokens', ['token'], unique=False)
|
||||
op.drop_index(op.f('ix_promotions_id'), table_name='promotions')
|
||||
op.drop_index(op.f('ix_promotions_code'), table_name='promotions')
|
||||
op.create_index('promotions_is_active', 'promotions', ['is_active'], unique=False)
|
||||
op.create_index('promotions_code', 'promotions', ['code'], unique=False)
|
||||
op.create_index('code', 'promotions', ['code'], unique=False)
|
||||
op.drop_constraint(None, 'payments', type_='foreignkey')
|
||||
op.drop_constraint(None, 'payments', type_='foreignkey')
|
||||
op.create_foreign_key('payments_related_payment_id_foreign_idx', 'payments', 'payments', ['related_payment_id'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
|
||||
op.create_foreign_key('payments_ibfk_1', 'payments', 'bookings', ['booking_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.drop_index(op.f('ix_payments_id'), table_name='payments')
|
||||
op.create_index('payments_payment_status', 'payments', ['payment_status'], unique=False)
|
||||
op.create_index('payments_booking_id', 'payments', ['booking_id'], unique=False)
|
||||
op.alter_column('payments', 'deposit_percentage',
|
||||
existing_type=mysql.INTEGER(),
|
||||
comment='Percentage of deposit (e.g., 20, 30, 50)',
|
||||
existing_nullable=True)
|
||||
op.drop_constraint(None, 'password_reset_tokens', type_='foreignkey')
|
||||
op.create_foreign_key('password_reset_tokens_ibfk_1', 'password_reset_tokens', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
|
||||
op.drop_index(op.f('ix_password_reset_tokens_token'), table_name='password_reset_tokens')
|
||||
op.drop_index(op.f('ix_password_reset_tokens_id'), table_name='password_reset_tokens')
|
||||
op.create_index('token', 'password_reset_tokens', ['token'], unique=False)
|
||||
op.create_index('password_reset_tokens_user_id', 'password_reset_tokens', ['user_id'], unique=False)
|
||||
op.create_index('password_reset_tokens_token', 'password_reset_tokens', ['token'], unique=False)
|
||||
op.alter_column('password_reset_tokens', 'used',
|
||||
existing_type=mysql.TINYINT(display_width=1),
|
||||
nullable=True,
|
||||
existing_server_default=sa.text("'0'"))
|
||||
op.drop_column('page_contents', 'partners_section_subtitle')
|
||||
op.drop_column('page_contents', 'partners_section_title')
|
||||
op.drop_column('page_contents', 'awards_section_subtitle')
|
||||
op.drop_column('page_contents', 'awards_section_title')
|
||||
op.drop_column('page_contents', 'luxury_experiences_section_subtitle')
|
||||
op.drop_column('page_contents', 'luxury_experiences_section_title')
|
||||
op.drop_column('page_contents', 'luxury_services_section_subtitle')
|
||||
op.drop_column('page_contents', 'luxury_services_section_title')
|
||||
op.drop_column('page_contents', 'luxury_testimonials_section_subtitle')
|
||||
op.drop_column('page_contents', 'luxury_testimonials_section_title')
|
||||
op.drop_column('page_contents', 'luxury_gallery_section_subtitle')
|
||||
op.drop_column('page_contents', 'luxury_gallery_section_title')
|
||||
op.drop_constraint(None, 'favorites', type_='foreignkey')
|
||||
op.drop_constraint(None, 'favorites', type_='foreignkey')
|
||||
op.create_foreign_key('favorites_ibfk_2', 'favorites', 'rooms', ['room_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
|
||||
op.create_foreign_key('favorites_ibfk_1', 'favorites', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
|
||||
op.drop_index(op.f('ix_favorites_id'), table_name='favorites')
|
||||
op.create_index('unique_user_room_favorite', 'favorites', ['user_id', 'room_id'], unique=False)
|
||||
op.create_index('favorites_user_id', 'favorites', ['user_id'], unique=False)
|
||||
op.create_index('favorites_room_id', 'favorites', ['room_id'], unique=False)
|
||||
op.drop_constraint(None, 'checkin_checkout', type_='foreignkey')
|
||||
op.drop_constraint(None, 'checkin_checkout', type_='foreignkey')
|
||||
op.drop_constraint(None, 'checkin_checkout', type_='foreignkey')
|
||||
op.create_foreign_key('checkin_checkout_ibfk_3', 'checkin_checkout', 'users', ['checkout_by'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
|
||||
op.create_foreign_key('checkin_checkout_ibfk_2', 'checkin_checkout', 'users', ['checkin_by'], ['id'], onupdate='CASCADE', ondelete='SET NULL')
|
||||
op.create_foreign_key('checkin_checkout_ibfk_1', 'checkin_checkout', 'bookings', ['booking_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.drop_constraint(None, 'checkin_checkout', type_='unique')
|
||||
op.drop_index(op.f('ix_checkin_checkout_id'), table_name='checkin_checkout')
|
||||
op.create_index('checkin_checkout_booking_id', 'checkin_checkout', ['booking_id'], unique=False)
|
||||
op.drop_constraint(None, 'bookings', type_='foreignkey')
|
||||
op.drop_constraint(None, 'bookings', type_='foreignkey')
|
||||
op.create_foreign_key('bookings_ibfk_2', 'bookings', 'rooms', ['room_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.create_foreign_key('bookings_ibfk_1', 'bookings', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT')
|
||||
op.drop_index(op.f('ix_bookings_id'), table_name='bookings')
|
||||
op.drop_index(op.f('ix_bookings_booking_number'), table_name='bookings')
|
||||
op.create_index('ix_bookings_promotion_code', 'bookings', ['promotion_code'], unique=False)
|
||||
op.create_index('bookings_user_id', 'bookings', ['user_id'], unique=False)
|
||||
op.create_index('bookings_status', 'bookings', ['status'], unique=False)
|
||||
op.create_index('bookings_room_id', 'bookings', ['room_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
"""add_luxury_section_fields_to_page_content
|
||||
|
||||
Revision ID: 17efc6439cc3
|
||||
Revises: bfa74be4b256
|
||||
Create Date: 2025-11-20 13:37:20.015422
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '17efc6439cc3'
|
||||
down_revision = 'bfa74be4b256'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add luxury section fields to page_contents table
|
||||
# Use TEXT instead of VARCHAR to avoid MySQL row size limits
|
||||
op.add_column('page_contents', sa.Column('luxury_section_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_section_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_section_image', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('luxury_features', sa.Text(), nullable=True)) # JSON array
|
||||
op.add_column('page_contents', sa.Column('luxury_gallery', sa.Text(), nullable=True)) # JSON array of image URLs
|
||||
op.add_column('page_contents', sa.Column('luxury_testimonials', sa.Text(), nullable=True)) # JSON array of testimonials
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove luxury section fields
|
||||
op.drop_column('page_contents', 'luxury_testimonials')
|
||||
op.drop_column('page_contents', 'luxury_gallery')
|
||||
op.drop_column('page_contents', 'luxury_features')
|
||||
op.drop_column('page_contents', 'luxury_section_image')
|
||||
op.drop_column('page_contents', 'luxury_section_subtitle')
|
||||
op.drop_column('page_contents', 'luxury_section_title')
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36
Backend/alembic/versions/add_about_page_fields.py
Normal file
36
Backend/alembic/versions/add_about_page_fields.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""add_about_page_fields
|
||||
|
||||
Revision ID: f2a3b4c5d6e7
|
||||
Revises: a1b2c3d4e5f6
|
||||
Create Date: 2025-11-20 17:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f2a3b4c5d6e7'
|
||||
down_revision = 'a1b2c3d4e5f6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add about page specific fields (all as TEXT to avoid row size issues)
|
||||
op.add_column('page_contents', sa.Column('about_hero_image', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('mission', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('vision', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('team', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('timeline', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('achievements', sa.Text(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove about page specific fields
|
||||
op.drop_column('page_contents', 'achievements')
|
||||
op.drop_column('page_contents', 'timeline')
|
||||
op.drop_column('page_contents', 'team')
|
||||
op.drop_column('page_contents', 'vision')
|
||||
op.drop_column('page_contents', 'mission')
|
||||
op.drop_column('page_contents', 'about_hero_image')
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"""add_copyright_text_to_page_content
|
||||
|
||||
Revision ID: a1b2c3d4e5f6
|
||||
Revises: ff515d77abbe
|
||||
Create Date: 2025-11-20 16:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a1b2c3d4e5f6'
|
||||
down_revision = '1444eb61188e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add copyright_text column to page_contents table
|
||||
op.add_column('page_contents', sa.Column('copyright_text', sa.Text(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove copyright_text column from page_contents table
|
||||
op.drop_column('page_contents', 'copyright_text')
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""add_luxury_content_fields_to_page_content
|
||||
|
||||
Revision ID: bfa74be4b256
|
||||
Revises: bd309b0742c1
|
||||
Create Date: 2025-11-20 13:27:52.106013
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bfa74be4b256'
|
||||
down_revision = 'bd309b0742c1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add luxury content fields to page_contents table
|
||||
op.add_column('page_contents', sa.Column('amenities_section_title', sa.String(500), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('amenities_section_subtitle', sa.String(1000), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('amenities', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('testimonials_section_title', sa.String(500), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('testimonials_section_subtitle', sa.String(1000), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('testimonials', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('gallery_section_title', sa.String(500), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('gallery_section_subtitle', sa.String(1000), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('gallery_images', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('about_preview_title', sa.String(500), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('about_preview_subtitle', sa.String(1000), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('about_preview_content', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('about_preview_image', sa.String(1000), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('stats', sa.Text(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove luxury content fields
|
||||
op.drop_column('page_contents', 'stats')
|
||||
op.drop_column('page_contents', 'about_preview_image')
|
||||
op.drop_column('page_contents', 'about_preview_content')
|
||||
op.drop_column('page_contents', 'about_preview_subtitle')
|
||||
op.drop_column('page_contents', 'about_preview_title')
|
||||
op.drop_column('page_contents', 'gallery_images')
|
||||
op.drop_column('page_contents', 'gallery_section_subtitle')
|
||||
op.drop_column('page_contents', 'gallery_section_title')
|
||||
op.drop_column('page_contents', 'testimonials')
|
||||
op.drop_column('page_contents', 'testimonials_section_subtitle')
|
||||
op.drop_column('page_contents', 'testimonials_section_title')
|
||||
op.drop_column('page_contents', 'amenities')
|
||||
op.drop_column('page_contents', 'amenities_section_subtitle')
|
||||
op.drop_column('page_contents', 'amenities_section_title')
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
"""add_more_luxury_sections_to_page_content
|
||||
|
||||
Revision ID: ff515d77abbe
|
||||
Revises: 17efc6439cc3
|
||||
Create Date: 2025-11-20 15:17:50.977961
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ff515d77abbe'
|
||||
down_revision = '17efc6439cc3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add more luxury sections to page_contents table
|
||||
op.add_column('page_contents', sa.Column('luxury_services', sa.Text(), nullable=True)) # JSON array of services
|
||||
op.add_column('page_contents', sa.Column('luxury_experiences', sa.Text(), nullable=True)) # JSON array of experiences
|
||||
op.add_column('page_contents', sa.Column('awards', sa.Text(), nullable=True)) # JSON array of awards
|
||||
op.add_column('page_contents', sa.Column('cta_title', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('cta_subtitle', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('cta_button_text', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('cta_button_link', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('cta_image', sa.Text(), nullable=True))
|
||||
op.add_column('page_contents', sa.Column('partners', sa.Text(), nullable=True)) # JSON array of partners
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove luxury sections fields
|
||||
op.drop_column('page_contents', 'partners')
|
||||
op.drop_column('page_contents', 'cta_image')
|
||||
op.drop_column('page_contents', 'cta_button_link')
|
||||
op.drop_column('page_contents', 'cta_button_text')
|
||||
op.drop_column('page_contents', 'cta_subtitle')
|
||||
op.drop_column('page_contents', 'cta_title')
|
||||
op.drop_column('page_contents', 'awards')
|
||||
op.drop_column('page_contents', 'luxury_experiences')
|
||||
op.drop_column('page_contents', 'luxury_services')
|
||||
|
||||
217
Backend/seed_about_page.py
Normal file
217
Backend/seed_about_page.py
Normal file
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Seed sample data for the About page
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
# Add the parent directory to the path so we can import from src
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from src.config.database import SessionLocal
|
||||
from src.models.page_content import PageContent, PageType
|
||||
from datetime import datetime
|
||||
|
||||
def get_db():
|
||||
"""Get database session"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
return db
|
||||
finally:
|
||||
pass
|
||||
|
||||
def seed_about_page(db: Session):
|
||||
"""Seed about page content"""
|
||||
print("=" * 80)
|
||||
print("SEEDING ABOUT PAGE CONTENT")
|
||||
print("=" * 80)
|
||||
|
||||
# Sample data
|
||||
about_data = {
|
||||
"title": "About Luxury Hotel",
|
||||
"subtitle": "Where Excellence Meets Unforgettable Experiences",
|
||||
"description": "Discover the story behind our commitment to luxury hospitality and exceptional service.",
|
||||
"story_content": """Welcome to Luxury Hotel, where timeless elegance meets modern sophistication. Since our founding in 2010, we have been dedicated to providing exceptional hospitality and creating unforgettable memories for our guests.
|
||||
|
||||
Nestled in the heart of the city, our hotel combines classic architecture with contemporary amenities, offering a perfect blend of comfort and luxury. Every detail has been carefully curated to ensure your stay exceeds expectations.
|
||||
|
||||
Our commitment to excellence extends beyond our beautiful rooms and facilities. We believe in creating meaningful connections with our guests, understanding their needs, and delivering personalized service that makes each visit special.
|
||||
|
||||
Over the years, we have hosted thousands of guests from around the world, each leaving with cherished memories and a desire to return. Our team of dedicated professionals works tirelessly to ensure that every moment of your stay is perfect.""",
|
||||
"mission": "To provide unparalleled luxury hospitality experiences that exceed expectations, creating lasting memories for our guests through exceptional service, attention to detail, and genuine care.",
|
||||
"vision": "To be recognized as the world's premier luxury hotel brand, setting the standard for excellence in hospitality while maintaining our commitment to sustainability and community engagement.",
|
||||
"about_hero_image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1920&h=1080&fit=crop",
|
||||
"values": json.dumps([
|
||||
{
|
||||
"icon": "Heart",
|
||||
"title": "Passion",
|
||||
"description": "We are passionate about hospitality and dedicated to creating exceptional experiences for every guest."
|
||||
},
|
||||
{
|
||||
"icon": "Award",
|
||||
"title": "Excellence",
|
||||
"description": "We strive for excellence in every aspect of our service, from the smallest detail to the grandest gesture."
|
||||
},
|
||||
{
|
||||
"icon": "Shield",
|
||||
"title": "Integrity",
|
||||
"description": "We conduct our business with honesty, transparency, and respect for our guests and community."
|
||||
},
|
||||
{
|
||||
"icon": "Users",
|
||||
"title": "Service",
|
||||
"description": "Our guests are at the heart of everything we do. Your comfort and satisfaction are our top priorities."
|
||||
}
|
||||
]),
|
||||
"features": json.dumps([
|
||||
{
|
||||
"icon": "Star",
|
||||
"title": "Premium Accommodations",
|
||||
"description": "Luxuriously appointed rooms and suites designed for ultimate comfort and relaxation."
|
||||
},
|
||||
{
|
||||
"icon": "Clock",
|
||||
"title": "24/7 Service",
|
||||
"description": "Round-the-clock concierge and room service to attend to your needs at any time."
|
||||
},
|
||||
{
|
||||
"icon": "Award",
|
||||
"title": "Award-Winning",
|
||||
"description": "Recognized for excellence in hospitality and guest satisfaction."
|
||||
}
|
||||
]),
|
||||
"team": json.dumps([
|
||||
{
|
||||
"name": "Sarah Johnson",
|
||||
"role": "General Manager",
|
||||
"image": "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=400&h=400&fit=crop",
|
||||
"bio": "With over 15 years of experience in luxury hospitality, Sarah leads our team with passion and dedication.",
|
||||
"social_links": {
|
||||
"linkedin": "https://linkedin.com/in/sarahjohnson",
|
||||
"twitter": "https://twitter.com/sarahjohnson"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Michael Chen",
|
||||
"role": "Head Chef",
|
||||
"image": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=400&fit=crop",
|
||||
"bio": "Award-winning chef with expertise in international cuisine, bringing world-class dining experiences to our guests.",
|
||||
"social_links": {
|
||||
"linkedin": "https://linkedin.com/in/michaelchen",
|
||||
"twitter": "https://twitter.com/michaelchen"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Emily Rodriguez",
|
||||
"role": "Guest Relations Manager",
|
||||
"image": "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=400&h=400&fit=crop",
|
||||
"bio": "Ensuring every guest feels valued and receives personalized attention throughout their stay.",
|
||||
"social_links": {
|
||||
"linkedin": "https://linkedin.com/in/emilyrodriguez"
|
||||
}
|
||||
}
|
||||
]),
|
||||
"timeline": json.dumps([
|
||||
{
|
||||
"year": "2010",
|
||||
"title": "Grand Opening",
|
||||
"description": "Luxury Hotel opened its doors, welcoming guests to a new standard of luxury hospitality.",
|
||||
"image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800&h=600&fit=crop"
|
||||
},
|
||||
{
|
||||
"year": "2015",
|
||||
"title": "First Award",
|
||||
"description": "Received our first 'Best Luxury Hotel' award, recognizing our commitment to excellence.",
|
||||
"image": "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800&h=600&fit=crop"
|
||||
},
|
||||
{
|
||||
"year": "2018",
|
||||
"title": "Major Renovation",
|
||||
"description": "Completed a comprehensive renovation, adding state-of-the-art facilities and expanding our capacity.",
|
||||
"image": "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800&h=600&fit=crop"
|
||||
},
|
||||
{
|
||||
"year": "2020",
|
||||
"title": "Sustainability Initiative",
|
||||
"description": "Launched our sustainability program, committing to eco-friendly practices and community engagement.",
|
||||
"image": "https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=800&h=600&fit=crop"
|
||||
},
|
||||
{
|
||||
"year": "2023",
|
||||
"title": "International Recognition",
|
||||
"description": "Achieved international recognition as one of the world's top luxury hotels.",
|
||||
"image": "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=800&h=600&fit=crop"
|
||||
}
|
||||
]),
|
||||
"achievements": json.dumps([
|
||||
{
|
||||
"icon": "Award",
|
||||
"title": "Best Luxury Hotel 2023",
|
||||
"description": "Recognized as the best luxury hotel in the region for exceptional service and amenities.",
|
||||
"year": "2023",
|
||||
"image": "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=400&h=300&fit=crop"
|
||||
},
|
||||
{
|
||||
"icon": "Star",
|
||||
"title": "5-Star Rating",
|
||||
"description": "Maintained our prestigious 5-star rating for over a decade, a testament to our consistent excellence.",
|
||||
"year": "2022",
|
||||
"image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=400&h=300&fit=crop"
|
||||
},
|
||||
{
|
||||
"icon": "Award",
|
||||
"title": "Sustainable Hotel of the Year",
|
||||
"description": "Awarded for our commitment to environmental sustainability and green practices.",
|
||||
"year": "2021",
|
||||
"image": "https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=400&h=300&fit=crop"
|
||||
},
|
||||
{
|
||||
"icon": "Users",
|
||||
"title": "Guest Satisfaction Excellence",
|
||||
"description": "Achieved 98% guest satisfaction rate, the highest in our category.",
|
||||
"year": "2023",
|
||||
"image": "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=400&h=300&fit=crop"
|
||||
}
|
||||
]),
|
||||
"meta_title": "About Us - Luxury Hotel | Our Story, Mission & Vision",
|
||||
"meta_description": "Learn about Luxury Hotel's commitment to excellence, our story, values, and the dedicated team that makes every stay unforgettable."
|
||||
}
|
||||
|
||||
# Check if about page content exists
|
||||
existing = db.query(PageContent).filter(PageContent.page_type == PageType.ABOUT).first()
|
||||
|
||||
if existing:
|
||||
# Update existing
|
||||
for key, value in about_data.items():
|
||||
setattr(existing, key, value)
|
||||
existing.updated_at = datetime.utcnow()
|
||||
print("✓ Updated existing about page content")
|
||||
else:
|
||||
# Create new
|
||||
new_content = PageContent(
|
||||
page_type=PageType.ABOUT,
|
||||
**about_data
|
||||
)
|
||||
db.add(new_content)
|
||||
print("✓ Created new about page content")
|
||||
|
||||
db.commit()
|
||||
print("\n✅ About page content seeded successfully!")
|
||||
print("=" * 80)
|
||||
|
||||
if __name__ == "__main__":
|
||||
db = get_db()
|
||||
try:
|
||||
seed_about_page(db)
|
||||
except Exception as e:
|
||||
print(f"\n❌ Error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
db.rollback()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
214
Backend/seed_banners_company.py
Normal file
214
Backend/seed_banners_company.py
Normal file
@@ -0,0 +1,214 @@
|
||||
"""
|
||||
Seed script to populate banners and company information with sample data.
|
||||
Run this script to add default banners and company settings.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# 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
|
||||
from src.models.banner import Banner
|
||||
from src.models.system_settings import SystemSettings
|
||||
from src.models.user import User
|
||||
|
||||
def seed_banners(db: Session):
|
||||
"""Seed sample banners"""
|
||||
print("Seeding banners...")
|
||||
|
||||
# Get admin user for updated_by_id (if exists)
|
||||
admin_user = db.query(User).filter(User.email == "admin@hotel.com").first()
|
||||
admin_id = admin_user.id if admin_user else None
|
||||
|
||||
# Delete all existing banners
|
||||
existing_banners = db.query(Banner).all()
|
||||
if existing_banners:
|
||||
for banner in existing_banners:
|
||||
db.delete(banner)
|
||||
db.commit()
|
||||
print(f" ✓ Removed {len(existing_banners)} existing banner(s)")
|
||||
|
||||
# New luxury banners with premium content
|
||||
banners_data = [
|
||||
{
|
||||
"title": "Welcome to Unparalleled Luxury",
|
||||
"description": "Where timeless elegance meets modern sophistication. Experience the pinnacle of hospitality in our award-winning luxury hotel.",
|
||||
"image_url": "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1920",
|
||||
"link_url": "/rooms",
|
||||
"position": "home",
|
||||
"display_order": 1,
|
||||
"is_active": True,
|
||||
"start_date": datetime.utcnow() - timedelta(days=30),
|
||||
"end_date": datetime.utcnow() + timedelta(days=365),
|
||||
},
|
||||
{
|
||||
"title": "Exclusive Presidential Suites",
|
||||
"description": "Indulge in our most opulent accommodations. Spacious suites with panoramic views, private terraces, and personalized butler service.",
|
||||
"image_url": "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1920",
|
||||
"link_url": "/rooms",
|
||||
"position": "home",
|
||||
"display_order": 2,
|
||||
"is_active": True,
|
||||
"start_date": datetime.utcnow() - timedelta(days=7),
|
||||
"end_date": datetime.utcnow() + timedelta(days=365),
|
||||
},
|
||||
{
|
||||
"title": "World-Class Spa & Wellness",
|
||||
"description": "Rejuvenate your mind, body, and soul. Our award-winning spa offers bespoke treatments using the finest luxury products.",
|
||||
"image_url": "https://images.unsplash.com/photo-1544161515-4ab6ce6db874?w=1920",
|
||||
"link_url": "/services",
|
||||
"position": "home",
|
||||
"display_order": 3,
|
||||
"is_active": True,
|
||||
"start_date": datetime.utcnow() - timedelta(days=1),
|
||||
"end_date": datetime.utcnow() + timedelta(days=365),
|
||||
},
|
||||
{
|
||||
"title": "Michelin-Starred Culinary Excellence",
|
||||
"description": "Savor extraordinary flavors crafted by world-renowned chefs. Our fine dining restaurants offer an unforgettable gastronomic journey.",
|
||||
"image_url": "https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=1920",
|
||||
"link_url": "/services",
|
||||
"position": "home",
|
||||
"display_order": 4,
|
||||
"is_active": True,
|
||||
"start_date": datetime.utcnow(),
|
||||
"end_date": datetime.utcnow() + timedelta(days=365),
|
||||
},
|
||||
{
|
||||
"title": "Private Yacht & Exclusive Experiences",
|
||||
"description": "Create unforgettable memories with our curated luxury experiences. From private yacht charters to exclusive cultural tours.",
|
||||
"image_url": "https://images.unsplash.com/photo-1544551763-46a013bb70d5?w=1920",
|
||||
"link_url": "/services",
|
||||
"position": "home",
|
||||
"display_order": 5,
|
||||
"is_active": True,
|
||||
"start_date": datetime.utcnow() - timedelta(days=15),
|
||||
"end_date": datetime.utcnow() + timedelta(days=365),
|
||||
}
|
||||
]
|
||||
|
||||
for banner_data in banners_data:
|
||||
# Create new banner
|
||||
new_banner = Banner(**banner_data)
|
||||
db.add(new_banner)
|
||||
print(f" ✓ Created banner: {banner_data['title']}")
|
||||
|
||||
db.commit()
|
||||
print("✓ Banners seeded successfully!\n")
|
||||
|
||||
def seed_company_info(db: Session):
|
||||
"""Seed company information"""
|
||||
print("Seeding company information...")
|
||||
|
||||
# Get admin user for updated_by_id (if exists)
|
||||
admin_user = db.query(User).filter(User.email == "admin@hotel.com").first()
|
||||
admin_id = admin_user.id if admin_user else None
|
||||
|
||||
# Company settings
|
||||
company_settings = [
|
||||
{
|
||||
"key": "company_name",
|
||||
"value": "Luxury Hotel",
|
||||
"description": "Company name displayed throughout the application"
|
||||
},
|
||||
{
|
||||
"key": "company_tagline",
|
||||
"value": "Experience Unparalleled Elegance",
|
||||
"description": "Company tagline or slogan"
|
||||
},
|
||||
{
|
||||
"key": "company_logo_url",
|
||||
"value": "",
|
||||
"description": "URL to company logo image (upload via admin dashboard)"
|
||||
},
|
||||
{
|
||||
"key": "company_favicon_url",
|
||||
"value": "",
|
||||
"description": "URL to company favicon image (upload via admin dashboard)"
|
||||
},
|
||||
{
|
||||
"key": "company_phone",
|
||||
"value": "+1 (555) 123-4567",
|
||||
"description": "Company contact phone number"
|
||||
},
|
||||
{
|
||||
"key": "company_email",
|
||||
"value": "info@luxuryhotel.com",
|
||||
"description": "Company contact email address"
|
||||
},
|
||||
{
|
||||
"key": "company_address",
|
||||
"value": "123 Luxury Avenue, Premium District, City 12345, Country",
|
||||
"description": "Company physical address"
|
||||
},
|
||||
{
|
||||
"key": "tax_rate",
|
||||
"value": "10.0",
|
||||
"description": "Default tax rate percentage (e.g., 10.0 for 10%)"
|
||||
},
|
||||
{
|
||||
"key": "platform_currency",
|
||||
"value": "EUR",
|
||||
"description": "Platform-wide currency setting for displaying prices"
|
||||
}
|
||||
]
|
||||
|
||||
for setting_data in company_settings:
|
||||
# Check if setting exists
|
||||
existing = db.query(SystemSettings).filter(
|
||||
SystemSettings.key == setting_data["key"]
|
||||
).first()
|
||||
|
||||
if existing:
|
||||
# Update existing setting
|
||||
existing.value = setting_data["value"]
|
||||
existing.description = setting_data["description"]
|
||||
if admin_id:
|
||||
existing.updated_by_id = admin_id
|
||||
print(f" ✓ Updated setting: {setting_data['key']}")
|
||||
else:
|
||||
# Create new setting
|
||||
new_setting = SystemSettings(
|
||||
key=setting_data["key"],
|
||||
value=setting_data["value"],
|
||||
description=setting_data["description"],
|
||||
updated_by_id=admin_id
|
||||
)
|
||||
db.add(new_setting)
|
||||
print(f" ✓ Created setting: {setting_data['key']}")
|
||||
|
||||
db.commit()
|
||||
print("✓ Company information seeded successfully!\n")
|
||||
|
||||
def main():
|
||||
"""Main seed function"""
|
||||
db: Session = SessionLocal()
|
||||
|
||||
try:
|
||||
print("=" * 80)
|
||||
print("SEEDING BANNERS AND COMPANY INFORMATION")
|
||||
print("=" * 80)
|
||||
print()
|
||||
|
||||
seed_banners(db)
|
||||
seed_company_info(db)
|
||||
|
||||
print("=" * 80)
|
||||
print("✓ All data seeded successfully!")
|
||||
print("=" * 80)
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
print(f"\n✗ Error seeding data: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
456
Backend/seed_homepage_footer.py
Normal file
456
Backend/seed_homepage_footer.py
Normal file
@@ -0,0 +1,456 @@
|
||||
"""
|
||||
Comprehensive seed script to populate homepage and footer with sample luxury content.
|
||||
Run this script to add default 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
|
||||
from src.models.page_content import PageContent, PageType
|
||||
|
||||
def seed_homepage_content(db: Session):
|
||||
"""Seed comprehensive homepage content"""
|
||||
existing = db.query(PageContent).filter(PageContent.page_type == PageType.HOME).first()
|
||||
|
||||
# Luxury Features
|
||||
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 Gallery
|
||||
luxury_gallery = [
|
||||
"https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800",
|
||||
"https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800",
|
||||
"https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=800",
|
||||
"https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=800",
|
||||
"https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800",
|
||||
"https://images.unsplash.com/photo-1551882547-ff40c63fe5fa?w=800"
|
||||
]
|
||||
|
||||
# Luxury Testimonials
|
||||
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": "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=200"
|
||||
},
|
||||
{
|
||||
"name": "Michael Chen",
|
||||
"title": "Travel Enthusiast",
|
||||
"quote": "The epitome of luxury. Every moment was perfect, from check-in to check-out.",
|
||||
"image": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200"
|
||||
},
|
||||
{
|
||||
"name": "Emma Williams",
|
||||
"title": "Luxury Traveler",
|
||||
"quote": "This hotel redefines what luxury means. I will definitely return.",
|
||||
"image": "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200"
|
||||
}
|
||||
]
|
||||
|
||||
# Luxury Services
|
||||
luxury_services = [
|
||||
{
|
||||
"icon": "UtensilsCrossed",
|
||||
"title": "Fine Dining",
|
||||
"description": "Michelin-starred restaurants offering world-class cuisine",
|
||||
"image": "https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=600"
|
||||
},
|
||||
{
|
||||
"icon": "Wine",
|
||||
"title": "Premium Bar",
|
||||
"description": "Extensive wine collection and craft cocktails in elegant settings",
|
||||
"image": "https://images.unsplash.com/photo-1514362545857-3bc16c4c7d1b?w=600"
|
||||
},
|
||||
{
|
||||
"icon": "Dumbbell",
|
||||
"title": "Spa & Wellness",
|
||||
"description": "Rejuvenating spa treatments and state-of-the-art fitness center",
|
||||
"image": "https://images.unsplash.com/photo-1544161515-4ab6ce6db874?w=600"
|
||||
},
|
||||
{
|
||||
"icon": "Car",
|
||||
"title": "Concierge Services",
|
||||
"description": "Personalized assistance for all your travel and entertainment needs",
|
||||
"image": "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=600"
|
||||
}
|
||||
]
|
||||
|
||||
# Luxury Experiences
|
||||
luxury_experiences = [
|
||||
{
|
||||
"icon": "Sunset",
|
||||
"title": "Sunset Rooftop",
|
||||
"description": "Breathtaking views and exclusive rooftop experiences",
|
||||
"image": "https://images.unsplash.com/photo-1514933651103-005eec06c04b?w=600"
|
||||
},
|
||||
{
|
||||
"icon": "Ship",
|
||||
"title": "Yacht Excursions",
|
||||
"description": "Private yacht charters for unforgettable sea adventures",
|
||||
"image": "https://images.unsplash.com/photo-1544551763-46a013bb70d5?w=600"
|
||||
},
|
||||
{
|
||||
"icon": "Music",
|
||||
"title": "Live Entertainment",
|
||||
"description": "World-class performances and exclusive events",
|
||||
"image": "https://images.unsplash.com/photo-1470229722913-7c0e2dbbafd3?w=600"
|
||||
},
|
||||
{
|
||||
"icon": "Palette",
|
||||
"title": "Art & Culture",
|
||||
"description": "Curated art collections and cultural experiences",
|
||||
"image": "https://images.unsplash.com/photo-1578301978018-3005759f48f7?w=600"
|
||||
}
|
||||
]
|
||||
|
||||
# Awards
|
||||
awards = [
|
||||
{
|
||||
"icon": "Trophy",
|
||||
"title": "Best Luxury Hotel 2024",
|
||||
"description": "Awarded by International Luxury Travel Association",
|
||||
"image": "https://images.unsplash.com/photo-1579783902614-a3fb3927b6a5?w=400",
|
||||
"year": "2024"
|
||||
},
|
||||
{
|
||||
"icon": "Star",
|
||||
"title": "5-Star Excellence",
|
||||
"description": "Consistently rated 5 stars by leading travel publications",
|
||||
"image": "https://images.unsplash.com/photo-1606761568499-6d2451b23c66?w=400",
|
||||
"year": "2023"
|
||||
},
|
||||
{
|
||||
"icon": "Award",
|
||||
"title": "Sustainable Luxury",
|
||||
"description": "Recognized for environmental responsibility and sustainability",
|
||||
"image": "https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=400",
|
||||
"year": "2024"
|
||||
}
|
||||
]
|
||||
|
||||
# Partners
|
||||
partners = [
|
||||
{
|
||||
"name": "Luxury Travel Group",
|
||||
"logo": "https://images.unsplash.com/photo-1599305445671-ac291c95aaa9?w=200",
|
||||
"link": "#"
|
||||
},
|
||||
{
|
||||
"name": "Premium Airlines",
|
||||
"logo": "https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=200",
|
||||
"link": "#"
|
||||
},
|
||||
{
|
||||
"name": "Exclusive Events",
|
||||
"logo": "https://images.unsplash.com/photo-1511578314322-379afb476865?w=200",
|
||||
"link": "#"
|
||||
},
|
||||
{
|
||||
"name": "Fine Dining Network",
|
||||
"logo": "https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=200",
|
||||
"link": "#"
|
||||
}
|
||||
]
|
||||
|
||||
# Stats
|
||||
stats = [
|
||||
{
|
||||
"icon": "Users",
|
||||
"number": "50,000+",
|
||||
"label": "Happy Guests"
|
||||
},
|
||||
{
|
||||
"icon": "Award",
|
||||
"number": "25+",
|
||||
"label": "Awards Won"
|
||||
},
|
||||
{
|
||||
"icon": "Star",
|
||||
"number": "4.9",
|
||||
"label": "Average Rating"
|
||||
},
|
||||
{
|
||||
"icon": "Globe",
|
||||
"number": "100+",
|
||||
"label": "Countries Served"
|
||||
}
|
||||
]
|
||||
|
||||
# Amenities
|
||||
amenities = [
|
||||
{
|
||||
"icon": "Wifi",
|
||||
"title": "High-Speed WiFi",
|
||||
"description": "Complimentary high-speed internet throughout the property",
|
||||
"image": ""
|
||||
},
|
||||
{
|
||||
"icon": "Coffee",
|
||||
"title": "24/7 Room Service",
|
||||
"description": "Round-the-clock dining and beverage service",
|
||||
"image": ""
|
||||
},
|
||||
{
|
||||
"icon": "Car",
|
||||
"title": "Valet Parking",
|
||||
"description": "Complimentary valet parking for all guests",
|
||||
"image": ""
|
||||
},
|
||||
{
|
||||
"icon": "Plane",
|
||||
"title": "Airport Transfer",
|
||||
"description": "Luxury airport transfer service available",
|
||||
"image": ""
|
||||
}
|
||||
]
|
||||
|
||||
# Testimonials
|
||||
testimonials = [
|
||||
{
|
||||
"name": "Robert Martinez",
|
||||
"role": "CEO, Tech Corp",
|
||||
"image": "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200",
|
||||
"rating": 5,
|
||||
"comment": "Exceptional service and attention to detail. The staff went above and beyond to make our stay memorable."
|
||||
},
|
||||
{
|
||||
"name": "Lisa Anderson",
|
||||
"role": "Travel Blogger",
|
||||
"image": "https://images.unsplash.com/photo-1487412720507-e7ab37603c6f?w=200",
|
||||
"rating": 5,
|
||||
"comment": "The most luxurious hotel experience I've ever had. Every detail was perfect."
|
||||
},
|
||||
{
|
||||
"name": "David Thompson",
|
||||
"role": "Investment Banker",
|
||||
"image": "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=200",
|
||||
"rating": 5,
|
||||
"comment": "Outstanding facilities and impeccable service. Highly recommend for business travelers."
|
||||
}
|
||||
]
|
||||
|
||||
# Gallery Images
|
||||
gallery_images = [
|
||||
"https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=800",
|
||||
"https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800",
|
||||
"https://images.unsplash.com/photo-1551882547-ff40c63fe5fa?w=800",
|
||||
"https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800",
|
||||
"https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=800",
|
||||
"https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800"
|
||||
]
|
||||
|
||||
homepage_data = {
|
||||
"page_type": PageType.HOME,
|
||||
"title": "Luxury Hotel - Experience Unparalleled Elegance",
|
||||
"subtitle": "Where timeless luxury meets modern sophistication",
|
||||
"description": "Discover a world of refined elegance and exceptional service",
|
||||
"hero_title": "Welcome to Luxury",
|
||||
"hero_subtitle": "Experience the pinnacle of hospitality",
|
||||
"hero_image": "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200",
|
||||
"luxury_section_title": "Experience Unparalleled Luxury",
|
||||
"luxury_section_subtitle": "Where elegance meets comfort in every detail",
|
||||
"luxury_section_image": "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=1200",
|
||||
"luxury_features": json.dumps(luxury_features),
|
||||
"luxury_gallery_section_title": "Our Luxury Gallery",
|
||||
"luxury_gallery_section_subtitle": "A glimpse into our world of elegance",
|
||||
"luxury_gallery": json.dumps(luxury_gallery),
|
||||
"luxury_testimonials_section_title": "What Our Guests Say",
|
||||
"luxury_testimonials_section_subtitle": "Testimonials from our valued guests",
|
||||
"luxury_testimonials": json.dumps(luxury_testimonials),
|
||||
"luxury_services_section_title": "Premium Services",
|
||||
"luxury_services_section_subtitle": "Indulge in our world-class amenities",
|
||||
"luxury_services": json.dumps(luxury_services),
|
||||
"luxury_experiences_section_title": "Exclusive Experiences",
|
||||
"luxury_experiences_section_subtitle": "Create unforgettable memories",
|
||||
"luxury_experiences": json.dumps(luxury_experiences),
|
||||
"awards_section_title": "Awards & Recognition",
|
||||
"awards_section_subtitle": "Recognized for excellence worldwide",
|
||||
"awards": json.dumps(awards),
|
||||
"partners_section_title": "Our Partners",
|
||||
"partners_section_subtitle": "Trusted by leading brands",
|
||||
"partners": json.dumps(partners),
|
||||
"amenities_section_title": "Premium Amenities",
|
||||
"amenities_section_subtitle": "Everything you need for a perfect stay",
|
||||
"amenities": json.dumps(amenities),
|
||||
"testimonials_section_title": "Guest Reviews",
|
||||
"testimonials_section_subtitle": "Hear from our satisfied guests",
|
||||
"testimonials": json.dumps(testimonials),
|
||||
"gallery_section_title": "Photo Gallery",
|
||||
"gallery_section_subtitle": "Explore our beautiful spaces",
|
||||
"gallery_images": json.dumps(gallery_images),
|
||||
"about_preview_title": "About Our Luxury Hotel",
|
||||
"about_preview_subtitle": "A legacy of excellence",
|
||||
"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. With over 50,000 satisfied guests and numerous awards, we continue to set the standard for luxury hospitality.",
|
||||
"about_preview_image": "https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=800",
|
||||
"stats": json.dumps(stats),
|
||||
"cta_title": "Ready to Experience Luxury?",
|
||||
"cta_subtitle": "Book your stay today and discover the difference",
|
||||
"cta_button_text": "Book Now",
|
||||
"cta_button_link": "/rooms",
|
||||
"cta_image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200",
|
||||
"is_active": True
|
||||
}
|
||||
|
||||
if existing:
|
||||
for key, value in homepage_data.items():
|
||||
if key != "page_type":
|
||||
setattr(existing, key, value)
|
||||
print("✓ Updated existing homepage content")
|
||||
else:
|
||||
new_content = PageContent(**homepage_data)
|
||||
db.add(new_content)
|
||||
print("✓ Created new homepage content")
|
||||
|
||||
db.commit()
|
||||
|
||||
def seed_footer_content(db: Session):
|
||||
"""Seed comprehensive footer content"""
|
||||
existing = db.query(PageContent).filter(PageContent.page_type == PageType.FOOTER).first()
|
||||
|
||||
# Contact Info
|
||||
contact_info = {
|
||||
"phone": "+1 (555) 123-4567",
|
||||
"email": "info@luxuryhotel.com",
|
||||
"address": "123 Luxury Avenue, Premium District, City 12345"
|
||||
}
|
||||
|
||||
# Social Links
|
||||
social_links = {
|
||||
"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"
|
||||
}
|
||||
|
||||
# Footer Links
|
||||
footer_links = {
|
||||
"quick_links": [
|
||||
{"label": "Home", "url": "/"},
|
||||
{"label": "Rooms & Suites", "url": "/rooms"},
|
||||
{"label": "About Us", "url": "/about"},
|
||||
{"label": "Contact", "url": "/contact"},
|
||||
{"label": "Gallery", "url": "/gallery"}
|
||||
],
|
||||
"support_links": [
|
||||
{"label": "FAQ", "url": "/faq"},
|
||||
{"label": "Privacy Policy", "url": "/privacy"},
|
||||
{"label": "Terms of Service", "url": "/terms"},
|
||||
{"label": "Cancellation Policy", "url": "/cancellation"},
|
||||
{"label": "Accessibility", "url": "/accessibility"}
|
||||
]
|
||||
}
|
||||
|
||||
# Badges
|
||||
badges = [
|
||||
{
|
||||
"text": "5-Star Rated",
|
||||
"icon": "Star"
|
||||
},
|
||||
{
|
||||
"text": "Award Winning",
|
||||
"icon": "Award"
|
||||
},
|
||||
{
|
||||
"text": "Eco Certified",
|
||||
"icon": "Leaf"
|
||||
},
|
||||
{
|
||||
"text": "Luxury Collection",
|
||||
"icon": "Crown"
|
||||
}
|
||||
]
|
||||
|
||||
footer_data = {
|
||||
"page_type": PageType.FOOTER,
|
||||
"title": "Luxury Hotel",
|
||||
"subtitle": "Experience Unparalleled Elegance",
|
||||
"description": "Your gateway to luxury hospitality and exceptional service",
|
||||
"contact_info": json.dumps(contact_info),
|
||||
"social_links": json.dumps(social_links),
|
||||
"footer_links": json.dumps(footer_links),
|
||||
"badges": json.dumps(badges),
|
||||
"copyright_text": "© {YEAR} Luxury Hotel. All rights reserved.",
|
||||
"is_active": True
|
||||
}
|
||||
|
||||
if existing:
|
||||
for key, value in footer_data.items():
|
||||
if key != "page_type":
|
||||
setattr(existing, key, value)
|
||||
print("✓ Updated existing footer content")
|
||||
else:
|
||||
new_content = PageContent(**footer_data)
|
||||
db.add(new_content)
|
||||
print("✓ Created new footer content")
|
||||
|
||||
db.commit()
|
||||
|
||||
def main():
|
||||
"""Main seed function"""
|
||||
db: Session = SessionLocal()
|
||||
|
||||
try:
|
||||
print("=" * 80)
|
||||
print("SEEDING HOMEPAGE AND FOOTER CONTENT")
|
||||
print("=" * 80)
|
||||
print()
|
||||
|
||||
print("Seeding homepage content...")
|
||||
seed_homepage_content(db)
|
||||
|
||||
print("\nSeeding footer content...")
|
||||
seed_footer_content(db)
|
||||
|
||||
print("\n" + "=" * 80)
|
||||
print("✓ All content seeded successfully!")
|
||||
print("=" * 80)
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
print(f"\n✗ Error seeding content: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
123
Backend/seed_luxury_content.py
Normal file
123
Backend/seed_luxury_content.py
Normal file
@@ -0,0 +1,123 @@
|
||||
"""
|
||||
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!")
|
||||
|
||||
317
Backend/seed_rooms.py
Normal file
317
Backend/seed_rooms.py
Normal file
@@ -0,0 +1,317 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Seed script to delete all existing rooms and create 50 sample luxury hotel rooms
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Add the parent directory to the path so we can import from src
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from src.config.database import SessionLocal, engine
|
||||
from src.models.room import Room, RoomStatus
|
||||
from src.models.room_type import RoomType
|
||||
from datetime import datetime
|
||||
import json
|
||||
import random
|
||||
|
||||
def get_db():
|
||||
"""Get database session"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
return db
|
||||
finally:
|
||||
pass
|
||||
|
||||
def seed_rooms(db: Session):
|
||||
"""Delete all existing rooms and create 50 sample luxury rooms"""
|
||||
print("=" * 80)
|
||||
print("SEEDING ROOMS - DELETING EXISTING AND CREATING 50 NEW LUXURY ROOMS")
|
||||
print("=" * 80)
|
||||
|
||||
# Get all room types
|
||||
room_types = db.query(RoomType).all()
|
||||
if not room_types:
|
||||
print("❌ No room types found! Please create room types first.")
|
||||
return
|
||||
|
||||
print(f"\n✓ Found {len(room_types)} room type(s)")
|
||||
for rt in room_types:
|
||||
print(f" - {rt.name} (ID: {rt.id}, Base Price: {rt.base_price})")
|
||||
|
||||
# Delete all existing rooms
|
||||
# First, we need to handle related records that reference these rooms
|
||||
from src.models.booking import Booking
|
||||
from src.models.review import Review
|
||||
from src.models.favorite import Favorite
|
||||
|
||||
existing_rooms = db.query(Room).all()
|
||||
if existing_rooms:
|
||||
print(f"\n🗑️ Deleting {len(existing_rooms)} existing room(s)...")
|
||||
|
||||
# Get all room IDs
|
||||
room_ids = [room.id for room in existing_rooms]
|
||||
|
||||
# Delete bookings that reference these rooms
|
||||
bookings_with_rooms = db.query(Booking).filter(Booking.room_id.in_(room_ids)).all()
|
||||
if bookings_with_rooms:
|
||||
print(f" ⚠️ Found {len(bookings_with_rooms)} booking(s) referencing these rooms")
|
||||
for booking in bookings_with_rooms:
|
||||
db.delete(booking)
|
||||
print(f" ✓ Deleted {len(bookings_with_rooms)} booking(s)")
|
||||
|
||||
# Delete reviews that reference these rooms
|
||||
reviews_with_rooms = db.query(Review).filter(Review.room_id.in_(room_ids)).all()
|
||||
if reviews_with_rooms:
|
||||
print(f" ⚠️ Found {len(reviews_with_rooms)} review(s) referencing these rooms")
|
||||
for review in reviews_with_rooms:
|
||||
db.delete(review)
|
||||
print(f" ✓ Deleted {len(reviews_with_rooms)} review(s)")
|
||||
|
||||
# Delete favorites that reference these rooms
|
||||
favorites_with_rooms = db.query(Favorite).filter(Favorite.room_id.in_(room_ids)).all()
|
||||
if favorites_with_rooms:
|
||||
print(f" ⚠️ Found {len(favorites_with_rooms)} favorite(s) referencing these rooms")
|
||||
for favorite in favorites_with_rooms:
|
||||
db.delete(favorite)
|
||||
print(f" ✓ Deleted {len(favorites_with_rooms)} favorite(s)")
|
||||
|
||||
# Now delete the rooms
|
||||
for room in existing_rooms:
|
||||
db.delete(room)
|
||||
db.commit()
|
||||
print(f"✓ Deleted {len(existing_rooms)} room(s)")
|
||||
|
||||
# Luxury room configurations
|
||||
views = [
|
||||
"Ocean View", "City View", "Garden View", "Mountain View",
|
||||
"Pool View", "Beach View", "Panoramic View", "Sea View"
|
||||
]
|
||||
|
||||
room_sizes = [
|
||||
"35 sqm", "40 sqm", "45 sqm", "50 sqm", "55 sqm",
|
||||
"60 sqm", "70 sqm", "80 sqm", "90 sqm", "100 sqm",
|
||||
"120 sqm", "150 sqm", "180 sqm", "200 sqm", "250 sqm"
|
||||
]
|
||||
|
||||
# Real luxury hotel room images from Unsplash (defined once, used for all rooms)
|
||||
luxury_room_images = [
|
||||
# Luxury hotel rooms
|
||||
"https://images.unsplash.com/photo-1631049307264-da0ec9d70304?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1578683010236-d716f9a3f461?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1596394516093-501ba68a0ba6?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1618221195710-dd6b41faaea8?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1566665797739-1674de7a421a?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&h=800&fit=crop",
|
||||
# Suite images
|
||||
"https://images.unsplash.com/photo-1618773928121-c32242e63f39?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1582719508461-905c673771fd?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1595576508898-0ad5c879a061?w=1200&h=800&fit=crop",
|
||||
# Additional luxury rooms
|
||||
"https://images.unsplash.com/photo-1571003123894-1f0594d2b5d9?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1578683010236-d716f9a3f461?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-1611892440504-42a792e24d32?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1618221195710-dd6b41faaea8?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1566665797739-1674de7a421a?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1618773928121-c32242e63f39?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1582719508461-905c673771fd?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1595576508898-0ad5c879a061?w=1200&h=800&fit=crop",
|
||||
"https://images.unsplash.com/photo-1571003123894-1f0594d2b5d9?w=1200&h=800&fit=crop",
|
||||
]
|
||||
|
||||
# Comprehensive luxury amenities
|
||||
all_amenities = [
|
||||
"Free WiFi", "High-Speed Internet", "Smart TV", "Netflix",
|
||||
"Air Conditioning", "Climate Control", "Private Balcony",
|
||||
"Ocean View", "City View", "Minibar", "Coffee Maker",
|
||||
"Espresso Machine", "Refrigerator", "Safe", "Iron & Ironing Board",
|
||||
"Hair Dryer", "Premium Toiletries", "Bathrobes", "Slippers",
|
||||
"Work Desk", "Ergonomic Chair", "USB Charging Ports",
|
||||
"Bluetooth Speaker", "Sound System", "Blackout Curtains",
|
||||
"Pillow Menu", "Turndown Service", "Room Service", "24/7 Concierge"
|
||||
]
|
||||
|
||||
premium_amenities = [
|
||||
"Jacuzzi Bathtub", "Steam Shower", "Rain Shower", "Bidet",
|
||||
"Private Pool", "Outdoor Terrace", "Fireplace", "Wine Cellar",
|
||||
"Private Bar", "Butler Service", "Private Elevator", "Helipad Access"
|
||||
]
|
||||
|
||||
# Room configurations: (floor_range, room_numbers_per_floor, view, size_range, amenities_count, featured)
|
||||
room_configs = [
|
||||
# Standard Rooms (Floors 1-3)
|
||||
((1, 3), 8, "Garden View", (35, 45), 8, False),
|
||||
((1, 3), 8, "City View", (40, 50), 9, False),
|
||||
|
||||
# Superior Rooms (Floors 4-6)
|
||||
((4, 6), 6, "City View", (45, 55), 10, False),
|
||||
((4, 6), 6, "Pool View", (50, 60), 11, True),
|
||||
|
||||
# Deluxe Rooms (Floors 7-9)
|
||||
((7, 9), 5, "Ocean View", (55, 70), 12, True),
|
||||
((7, 9), 5, "Mountain View", (60, 75), 12, False),
|
||||
|
||||
# Executive Suites (Floors 10-12)
|
||||
((10, 12), 4, "Panoramic View", (80, 100), 14, True),
|
||||
((10, 12), 4, "Sea View", (90, 110), 15, True),
|
||||
|
||||
# Luxury Suites (Floors 13-15)
|
||||
((13, 15), 3, "Ocean View", (120, 150), 16, True),
|
||||
((13, 15), 3, "Beach View", (130, 160), 17, True),
|
||||
|
||||
# Presidential Suites (Floor 16)
|
||||
((16, 16), 2, "Panoramic View", (200, 250), 20, True),
|
||||
]
|
||||
|
||||
rooms_created = []
|
||||
room_counter = 101 # Starting room number
|
||||
|
||||
print(f"\n🏨 Creating 50 luxury rooms...\n")
|
||||
|
||||
for config in room_configs:
|
||||
floor_range, rooms_per_floor, view_type, size_range, amenities_count, featured = config
|
||||
|
||||
for floor in range(floor_range[0], floor_range[1] + 1):
|
||||
for _ in range(rooms_per_floor):
|
||||
if len(rooms_created) >= 50:
|
||||
break
|
||||
|
||||
# Select random room type based on floor
|
||||
if floor <= 3:
|
||||
room_type = random.choice([rt for rt in room_types if 'standard' in rt.name.lower() or 'superior' in rt.name.lower()] or room_types)
|
||||
elif floor <= 6:
|
||||
room_type = random.choice([rt for rt in room_types if 'superior' in rt.name.lower() or 'deluxe' in rt.name.lower()] or room_types)
|
||||
elif floor <= 9:
|
||||
room_type = random.choice([rt for rt in room_types if 'deluxe' in rt.name.lower() or 'executive' in rt.name.lower()] or room_types)
|
||||
elif floor <= 12:
|
||||
room_type = random.choice([rt for rt in room_types if 'executive' in rt.name.lower() or 'suite' in rt.name.lower()] or room_types)
|
||||
else:
|
||||
room_type = random.choice([rt for rt in room_types if 'suite' in rt.name.lower() or 'presidential' in rt.name.lower()] or room_types)
|
||||
|
||||
# If no matching room type, use random
|
||||
if not room_type:
|
||||
room_type = random.choice(room_types)
|
||||
|
||||
# Calculate price (base price + floor premium + view premium + random variation)
|
||||
base_price = float(room_type.base_price)
|
||||
floor_premium = (floor - 1) * 5 # +5 per floor
|
||||
view_premium = 20 if "Ocean" in view_type or "Sea" in view_type or "Beach" in view_type else 0
|
||||
view_premium += 15 if "Panoramic" in view_type else 0
|
||||
view_premium += 10 if "Mountain" in view_type else 0
|
||||
view_premium += 5 if "Pool" in view_type else 0
|
||||
# Add random variation (-5% to +10% of base price)
|
||||
random_variation = base_price * random.uniform(-0.05, 0.10)
|
||||
# Size premium (larger rooms cost more)
|
||||
size_min, size_max = size_range
|
||||
size_premium = (size_min + size_max) / 2 * 0.5 # ~0.5 per sqm
|
||||
price = base_price + floor_premium + view_premium + random_variation + size_premium
|
||||
# Ensure minimum price and round to 2 decimal places
|
||||
price = max(base_price * 0.95, price)
|
||||
price = round(price, 2)
|
||||
|
||||
# Select amenities
|
||||
selected_amenities = random.sample(all_amenities, min(amenities_count, len(all_amenities)))
|
||||
if floor >= 13: # Add premium amenities for luxury suites
|
||||
premium_count = min(2, len(premium_amenities))
|
||||
selected_amenities.extend(random.sample(premium_amenities, premium_count))
|
||||
|
||||
# Room size
|
||||
size_min, size_max = size_range
|
||||
room_size = f"{random.randint(size_min, size_max)} sqm"
|
||||
|
||||
# Capacity (based on room type, with some variation)
|
||||
capacity = room_type.capacity
|
||||
if random.random() > 0.7: # 30% chance to have different capacity
|
||||
capacity = max(1, capacity + random.randint(-1, 1))
|
||||
|
||||
# Room number
|
||||
room_number = f"{floor}{room_counter % 100:02d}"
|
||||
room_counter += 1
|
||||
|
||||
# Select 3 unique images for each room (ensure we always have images)
|
||||
# Shuffle the list each time to get different combinations
|
||||
shuffled_images = luxury_room_images.copy()
|
||||
random.shuffle(shuffled_images)
|
||||
image_urls = shuffled_images[:3] # Always take first 3 after shuffle
|
||||
|
||||
# Description
|
||||
descriptions = [
|
||||
f"Elegantly designed {view_type.lower()} room with modern luxury amenities and breathtaking views.",
|
||||
f"Spacious {view_type.lower()} accommodation featuring premium furnishings and world-class comfort.",
|
||||
f"Luxurious {view_type.lower()} room with sophisticated decor and exceptional attention to detail.",
|
||||
f"Exquisite {view_type.lower()} suite offering unparalleled elegance and personalized service.",
|
||||
f"Opulent {view_type.lower()} accommodation with bespoke interiors and premium amenities.",
|
||||
]
|
||||
description = random.choice(descriptions)
|
||||
|
||||
# Status (mostly available, some in maintenance/cleaning)
|
||||
status_weights = [0.85, 0.05, 0.05, 0.05] # available, occupied, maintenance, cleaning
|
||||
status = random.choices(
|
||||
[RoomStatus.available, RoomStatus.occupied, RoomStatus.maintenance, RoomStatus.cleaning],
|
||||
weights=status_weights
|
||||
)[0]
|
||||
|
||||
# Create room
|
||||
room = Room(
|
||||
room_type_id=room_type.id,
|
||||
room_number=room_number,
|
||||
floor=floor,
|
||||
status=status,
|
||||
price=price,
|
||||
featured=featured,
|
||||
capacity=capacity,
|
||||
room_size=room_size,
|
||||
view=view_type,
|
||||
images=json.dumps(image_urls),
|
||||
amenities=json.dumps(selected_amenities),
|
||||
description=description
|
||||
)
|
||||
|
||||
db.add(room)
|
||||
rooms_created.append({
|
||||
'number': room_number,
|
||||
'floor': floor,
|
||||
'type': room_type.name,
|
||||
'view': view_type,
|
||||
'price': price
|
||||
})
|
||||
|
||||
print(f" ✓ Created Room {room_number} - Floor {floor}, {room_type.name}, {view_type}, {room_size}, €{price:.2f}")
|
||||
|
||||
db.commit()
|
||||
print(f"\n✅ Successfully created {len(rooms_created)} luxury rooms!")
|
||||
print(f"\n📊 Summary:")
|
||||
featured_count = sum(1 for r in rooms_created if any(
|
||||
config[5] and r['floor'] >= config[0][0] and r['floor'] <= config[0][1]
|
||||
for config in room_configs
|
||||
))
|
||||
print(f" - Featured rooms: {featured_count}")
|
||||
print(f" - Floors: {min(r['floor'] for r in rooms_created)} - {max(r['floor'] for r in rooms_created)}")
|
||||
print(f" - Price range: €{min(r['price'] for r in rooms_created):.2f} - €{max(r['price'] for r in rooms_created):.2f}")
|
||||
print("=" * 80)
|
||||
|
||||
if __name__ == "__main__":
|
||||
db = get_db()
|
||||
try:
|
||||
seed_rooms(db)
|
||||
except Exception as e:
|
||||
print(f"\n❌ Error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
db.rollback()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
Binary file not shown.
@@ -200,7 +200,8 @@ from .routes import (
|
||||
room_routes, booking_routes, payment_routes, invoice_routes, banner_routes,
|
||||
favorite_routes, service_routes, service_booking_routes, promotion_routes, report_routes,
|
||||
review_routes, user_routes, audit_routes, admin_privacy_routes,
|
||||
system_settings_routes, contact_routes, page_content_routes
|
||||
system_settings_routes, contact_routes, page_content_routes,
|
||||
home_routes, about_routes, contact_content_routes, footer_routes
|
||||
)
|
||||
|
||||
# Legacy routes (maintain backward compatibility)
|
||||
@@ -220,6 +221,10 @@ app.include_router(audit_routes.router, prefix="/api")
|
||||
app.include_router(admin_privacy_routes.router, prefix="/api")
|
||||
app.include_router(system_settings_routes.router, prefix="/api")
|
||||
app.include_router(contact_routes.router, prefix="/api")
|
||||
app.include_router(home_routes.router, prefix="/api")
|
||||
app.include_router(about_routes.router, prefix="/api")
|
||||
app.include_router(contact_content_routes.router, prefix="/api")
|
||||
app.include_router(footer_routes.router, prefix="/api")
|
||||
|
||||
# Versioned routes (v1)
|
||||
app.include_router(room_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
@@ -238,6 +243,10 @@ app.include_router(audit_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(admin_privacy_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(system_settings_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(contact_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(home_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(about_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(contact_content_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(footer_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
app.include_router(page_content_routes.router, prefix="/api")
|
||||
app.include_router(page_content_routes.router, prefix=settings.API_V1_PREFIX)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -8,6 +8,7 @@ import os
|
||||
from ..config.database import get_db
|
||||
from ..config.settings import settings
|
||||
from ..models.user import User
|
||||
from ..models.role import Role
|
||||
|
||||
security = HTTPBearer()
|
||||
|
||||
@@ -46,10 +47,20 @@ def authorize_roles(*allowed_roles: str):
|
||||
"""
|
||||
Check if user has required role
|
||||
"""
|
||||
def role_checker(current_user: User = Depends(get_current_user)) -> User:
|
||||
# Map role IDs to role names
|
||||
role_map = {1: "admin", 2: "staff", 3: "customer"}
|
||||
user_role_name = role_map.get(current_user.role_id)
|
||||
def role_checker(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
) -> User:
|
||||
# Query the role from database instead of using hardcoded IDs
|
||||
role = db.query(Role).filter(Role.id == current_user.role_id).first()
|
||||
|
||||
if not role:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="User role not found"
|
||||
)
|
||||
|
||||
user_role_name = role.name
|
||||
|
||||
if user_role_name not in allowed_roles:
|
||||
raise HTTPException(
|
||||
|
||||
Binary file not shown.
@@ -41,6 +41,7 @@ class PageContent(Base):
|
||||
social_links = Column(Text, nullable=True) # JSON: facebook, twitter, instagram, etc.
|
||||
footer_links = Column(Text, nullable=True) # JSON: quick links, support links
|
||||
badges = Column(Text, nullable=True) # JSON: array of badges with text and icon
|
||||
copyright_text = Column(Text, nullable=True) # Copyright text with {YEAR} placeholder for automatic year
|
||||
|
||||
# Home page specific
|
||||
hero_title = Column(String(500), nullable=True)
|
||||
@@ -51,6 +52,57 @@ class PageContent(Base):
|
||||
story_content = Column(Text, nullable=True)
|
||||
values = Column(Text, nullable=True) # JSON array of values
|
||||
features = Column(Text, nullable=True) # JSON array of features
|
||||
about_hero_image = Column(Text, nullable=True) # Hero image for about page
|
||||
mission = Column(Text, nullable=True) # Mission statement
|
||||
vision = Column(Text, nullable=True) # Vision statement
|
||||
team = Column(Text, nullable=True) # JSON array of team members with name, role, image, bio, social_links
|
||||
timeline = Column(Text, nullable=True) # JSON array of timeline events with year, title, description, image
|
||||
achievements = Column(Text, nullable=True) # JSON array of achievements with icon, title, description, year, image
|
||||
|
||||
# Home page luxury sections
|
||||
luxury_section_title = Column(Text, nullable=True)
|
||||
luxury_section_subtitle = Column(Text, nullable=True)
|
||||
luxury_section_image = Column(Text, nullable=True)
|
||||
luxury_features = Column(Text, nullable=True) # JSON array of features with icon, title, description
|
||||
luxury_gallery_section_title = Column(Text, nullable=True)
|
||||
luxury_gallery_section_subtitle = Column(Text, nullable=True)
|
||||
luxury_gallery = Column(Text, nullable=True) # JSON array of image URLs
|
||||
luxury_testimonials_section_title = Column(Text, nullable=True)
|
||||
luxury_testimonials_section_subtitle = Column(Text, nullable=True)
|
||||
luxury_testimonials = Column(Text, nullable=True) # JSON array of testimonials
|
||||
amenities_section_title = Column(String(500), nullable=True)
|
||||
amenities_section_subtitle = Column(String(1000), nullable=True)
|
||||
amenities = Column(Text, nullable=True) # JSON array of amenities with icon, title, description, image
|
||||
testimonials_section_title = Column(String(500), nullable=True)
|
||||
testimonials_section_subtitle = Column(String(1000), nullable=True)
|
||||
testimonials = Column(Text, nullable=True) # JSON array of testimonials with name, role, image, rating, comment
|
||||
gallery_section_title = Column(String(500), nullable=True)
|
||||
gallery_section_subtitle = Column(String(1000), nullable=True)
|
||||
gallery_images = Column(Text, nullable=True) # JSON array of image URLs
|
||||
about_preview_title = Column(String(500), nullable=True)
|
||||
about_preview_subtitle = Column(String(1000), nullable=True)
|
||||
about_preview_content = Column(Text, nullable=True)
|
||||
about_preview_image = Column(String(1000), nullable=True)
|
||||
stats = Column(Text, nullable=True) # JSON array of stats with number, label, icon
|
||||
|
||||
# Additional luxury sections
|
||||
luxury_services_section_title = Column(Text, nullable=True)
|
||||
luxury_services_section_subtitle = Column(Text, nullable=True)
|
||||
luxury_services = Column(Text, nullable=True) # JSON array of services with icon, title, description, image
|
||||
luxury_experiences_section_title = Column(Text, nullable=True)
|
||||
luxury_experiences_section_subtitle = Column(Text, nullable=True)
|
||||
luxury_experiences = Column(Text, nullable=True) # JSON array of experiences with icon, title, description, image
|
||||
awards_section_title = Column(Text, nullable=True)
|
||||
awards_section_subtitle = Column(Text, nullable=True)
|
||||
awards = Column(Text, nullable=True) # JSON array of awards with icon, title, description, image, year
|
||||
cta_title = Column(Text, nullable=True)
|
||||
cta_subtitle = Column(Text, nullable=True)
|
||||
cta_button_text = Column(Text, nullable=True)
|
||||
cta_button_link = Column(Text, nullable=True)
|
||||
cta_image = Column(Text, nullable=True)
|
||||
partners_section_title = Column(Text, nullable=True)
|
||||
partners_section_subtitle = Column(Text, nullable=True)
|
||||
partners = Column(Text, nullable=True) # JSON array of partners with name, logo, link
|
||||
|
||||
# Status
|
||||
is_active = Column(Boolean, default=True, nullable=False)
|
||||
|
||||
BIN
Backend/src/routes/__pycache__/about_routes.cpython-312.pyc
Normal file
BIN
Backend/src/routes/__pycache__/about_routes.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Backend/src/routes/__pycache__/footer_routes.cpython-312.pyc
Normal file
BIN
Backend/src/routes/__pycache__/footer_routes.cpython-312.pyc
Normal file
Binary file not shown.
BIN
Backend/src/routes/__pycache__/home_routes.cpython-312.pyc
Normal file
BIN
Backend/src/routes/__pycache__/home_routes.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
75
Backend/src/routes/about_routes.py
Normal file
75
Backend/src/routes/about_routes.py
Normal file
@@ -0,0 +1,75 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
import json
|
||||
|
||||
from ..config.database import get_db
|
||||
from ..config.logging_config import get_logger
|
||||
from ..models.page_content import PageContent, PageType
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/about", tags=["about"])
|
||||
|
||||
|
||||
def serialize_page_content(content: PageContent) -> dict:
|
||||
"""Serialize PageContent model to dictionary"""
|
||||
return {
|
||||
"id": content.id,
|
||||
"page_type": content.page_type.value,
|
||||
"title": content.title,
|
||||
"subtitle": content.subtitle,
|
||||
"description": content.description,
|
||||
"content": content.content,
|
||||
"meta_title": content.meta_title,
|
||||
"meta_description": content.meta_description,
|
||||
"meta_keywords": content.meta_keywords,
|
||||
"og_title": content.og_title,
|
||||
"og_description": content.og_description,
|
||||
"og_image": content.og_image,
|
||||
"canonical_url": content.canonical_url,
|
||||
"story_content": content.story_content,
|
||||
"values": json.loads(content.values) if content.values else None,
|
||||
"features": json.loads(content.features) if content.features else None,
|
||||
"about_hero_image": content.about_hero_image,
|
||||
"mission": content.mission,
|
||||
"vision": content.vision,
|
||||
"team": json.loads(content.team) if content.team else None,
|
||||
"timeline": json.loads(content.timeline) if content.timeline else None,
|
||||
"achievements": json.loads(content.achievements) if content.achievements else None,
|
||||
"is_active": content.is_active,
|
||||
"created_at": content.created_at.isoformat() if content.created_at else None,
|
||||
"updated_at": content.updated_at.isoformat() if content.updated_at else None,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_about_content(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get about page content"""
|
||||
try:
|
||||
content = db.query(PageContent).filter(PageContent.page_type == PageType.ABOUT).first()
|
||||
|
||||
if not content:
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": None
|
||||
}
|
||||
}
|
||||
|
||||
content_dict = serialize_page_content(content)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": content_dict
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching about content: {str(e)}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Error fetching about content: {str(e)}"
|
||||
)
|
||||
|
||||
@@ -495,6 +495,7 @@ async def upload_avatar(
|
||||
full_url = normalize_image_url(image_url, base_url)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": "Avatar uploaded successfully",
|
||||
"data": {
|
||||
|
||||
@@ -246,11 +246,25 @@ async def upload_banner_image(
|
||||
):
|
||||
"""Upload banner image (Admin only)"""
|
||||
try:
|
||||
# Validate file exists
|
||||
if not image:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="No file provided"
|
||||
)
|
||||
|
||||
# Validate file type
|
||||
if not image.content_type or not image.content_type.startswith('image/'):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="File must be an image"
|
||||
detail=f"File must be an image. Received: {image.content_type}"
|
||||
)
|
||||
|
||||
# Validate filename
|
||||
if not image.filename:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Filename is required"
|
||||
)
|
||||
|
||||
# Create uploads directory
|
||||
@@ -258,21 +272,27 @@ async def upload_banner_image(
|
||||
upload_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Generate filename
|
||||
ext = Path(image.filename).suffix
|
||||
ext = Path(image.filename).suffix or '.jpg'
|
||||
filename = f"banner-{uuid.uuid4()}{ext}"
|
||||
file_path = upload_dir / filename
|
||||
|
||||
# Save file
|
||||
async with aiofiles.open(file_path, 'wb') as f:
|
||||
content = await image.read()
|
||||
if not content:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="File is empty"
|
||||
)
|
||||
await f.write(content)
|
||||
|
||||
# Return the image URL
|
||||
image_url = f"/uploads/banners/{filename}"
|
||||
base_url = get_base_url(request)
|
||||
full_url = normalize_image_url(image_url, base_url)
|
||||
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": "Image uploaded successfully",
|
||||
"data": {
|
||||
|
||||
@@ -61,6 +61,11 @@ def _generate_invoice_email_html(invoice: dict, is_proforma: bool = False) -> st
|
||||
text-align: center;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}}
|
||||
.company-logo {{
|
||||
max-width: 150px;
|
||||
max-height: 80px;
|
||||
margin-bottom: 10px;
|
||||
}}
|
||||
.content {{
|
||||
background-color: #ffffff;
|
||||
padding: 30px;
|
||||
@@ -109,6 +114,8 @@ def _generate_invoice_email_html(invoice: dict, is_proforma: bool = False) -> st
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
{f'<img src="{invoice.get("company_logo_url")}" alt="Company Logo" class="company-logo" />' if invoice.get('company_logo_url') else ''}
|
||||
{f'<h2 style="margin: 10px 0; color: #0f0f0f;">{invoice.get("company_name", "")}</h2>' if invoice.get('company_name') else ''}
|
||||
<h1>{invoice_type}</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
@@ -139,6 +146,7 @@ def _generate_invoice_email_html(invoice: dict, is_proforma: bool = False) -> st
|
||||
<div class="total">
|
||||
<p>Subtotal: {invoice.get('subtotal', 0):.2f}</p>
|
||||
{f'<p style="color: #059669;">Discount: -{invoice.get("discount_amount", 0):.2f}</p>' if invoice.get('discount_amount', 0) > 0 else ''}
|
||||
{f'<p style="color: #059669; font-size: 14px;">Promotion Code: {invoice.get("promotion_code", "")}</p>' if invoice.get('promotion_code') else ''}
|
||||
<p>Tax: {invoice.get('tax_amount', 0):.2f}</p>
|
||||
<p><strong>Total Amount: {invoice.get('total_amount', 0):.2f}</strong></p>
|
||||
<p>Amount Paid: {invoice.get('amount_paid', 0):.2f}</p>
|
||||
@@ -729,19 +737,31 @@ async def create_booking(
|
||||
# Get discount from booking
|
||||
booking_discount = float(booking.discount_amount) if booking.discount_amount else 0.0
|
||||
|
||||
# Add promotion code to invoice notes if present
|
||||
invoice_notes = invoice_kwargs.get("notes", "")
|
||||
if booking.promotion_code:
|
||||
promotion_note = f"Promotion Code: {booking.promotion_code}"
|
||||
invoice_notes = f"{promotion_note}\n{invoice_notes}".strip() if invoice_notes else promotion_note
|
||||
invoice_kwargs["notes"] = invoice_notes
|
||||
|
||||
# Create invoices based on payment method
|
||||
if payment_method == "cash":
|
||||
# For cash bookings: create invoice for 20% deposit + proforma for 80% remaining
|
||||
deposit_amount = float(total_price) * 0.2
|
||||
remaining_amount = float(total_price) * 0.8
|
||||
|
||||
# Calculate proportional discount for partial invoices
|
||||
# Deposit invoice gets 20% of the discount, proforma gets 80%
|
||||
deposit_discount = booking_discount * 0.2 if booking_discount > 0 else 0.0
|
||||
proforma_discount = booking_discount * 0.8 if booking_discount > 0 else 0.0
|
||||
|
||||
# Create invoice for deposit (20%)
|
||||
deposit_invoice = InvoiceService.create_invoice_from_booking(
|
||||
booking_id=booking.id,
|
||||
db=db,
|
||||
created_by_id=current_user.id,
|
||||
tax_rate=tax_rate,
|
||||
discount_amount=booking_discount,
|
||||
discount_amount=deposit_discount,
|
||||
due_days=30,
|
||||
is_proforma=False,
|
||||
invoice_amount=deposit_amount,
|
||||
@@ -754,7 +774,7 @@ async def create_booking(
|
||||
db=db,
|
||||
created_by_id=current_user.id,
|
||||
tax_rate=tax_rate,
|
||||
discount_amount=booking_discount,
|
||||
discount_amount=proforma_discount,
|
||||
due_days=30,
|
||||
is_proforma=True,
|
||||
invoice_amount=remaining_amount,
|
||||
|
||||
68
Backend/src/routes/contact_content_routes.py
Normal file
68
Backend/src/routes/contact_content_routes.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
import json
|
||||
|
||||
from ..config.database import get_db
|
||||
from ..config.logging_config import get_logger
|
||||
from ..models.page_content import PageContent, PageType
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/contact-content", tags=["contact-content"])
|
||||
|
||||
|
||||
def serialize_page_content(content: PageContent) -> dict:
|
||||
"""Serialize PageContent model to dictionary"""
|
||||
return {
|
||||
"id": content.id,
|
||||
"page_type": content.page_type.value,
|
||||
"title": content.title,
|
||||
"subtitle": content.subtitle,
|
||||
"description": content.description,
|
||||
"content": content.content,
|
||||
"meta_title": content.meta_title,
|
||||
"meta_description": content.meta_description,
|
||||
"meta_keywords": content.meta_keywords,
|
||||
"og_title": content.og_title,
|
||||
"og_description": content.og_description,
|
||||
"og_image": content.og_image,
|
||||
"canonical_url": content.canonical_url,
|
||||
"contact_info": json.loads(content.contact_info) if content.contact_info else None,
|
||||
"map_url": content.map_url,
|
||||
"is_active": content.is_active,
|
||||
"created_at": content.created_at.isoformat() if content.created_at else None,
|
||||
"updated_at": content.updated_at.isoformat() if content.updated_at else None,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_contact_content(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get contact page content"""
|
||||
try:
|
||||
content = db.query(PageContent).filter(PageContent.page_type == PageType.CONTACT).first()
|
||||
|
||||
if not content:
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": None
|
||||
}
|
||||
}
|
||||
|
||||
content_dict = serialize_page_content(content)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": content_dict
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching contact content: {str(e)}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Error fetching contact content: {str(e)}"
|
||||
)
|
||||
|
||||
63
Backend/src/routes/footer_routes.py
Normal file
63
Backend/src/routes/footer_routes.py
Normal file
@@ -0,0 +1,63 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
import json
|
||||
|
||||
from ..config.database import get_db
|
||||
from ..config.logging_config import get_logger
|
||||
from ..models.page_content import PageContent, PageType
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/footer", tags=["footer"])
|
||||
|
||||
|
||||
def serialize_page_content(content: PageContent) -> dict:
|
||||
"""Serialize PageContent model to dictionary"""
|
||||
return {
|
||||
"id": content.id,
|
||||
"page_type": content.page_type.value,
|
||||
"title": content.title,
|
||||
"subtitle": content.subtitle,
|
||||
"description": content.description,
|
||||
"content": content.content,
|
||||
"social_links": json.loads(content.social_links) if content.social_links else None,
|
||||
"footer_links": json.loads(content.footer_links) if content.footer_links else None,
|
||||
"badges": json.loads(content.badges) if content.badges else None,
|
||||
"copyright_text": content.copyright_text,
|
||||
"is_active": content.is_active,
|
||||
"created_at": content.created_at.isoformat() if content.created_at else None,
|
||||
"updated_at": content.updated_at.isoformat() if content.updated_at else None,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_footer_content(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get footer content"""
|
||||
try:
|
||||
content = db.query(PageContent).filter(PageContent.page_type == PageType.FOOTER).first()
|
||||
|
||||
if not content:
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": None
|
||||
}
|
||||
}
|
||||
|
||||
content_dict = serialize_page_content(content)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": content_dict
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching footer content: {str(e)}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Error fetching footer content: {str(e)}"
|
||||
)
|
||||
|
||||
110
Backend/src/routes/home_routes.py
Normal file
110
Backend/src/routes/home_routes.py
Normal file
@@ -0,0 +1,110 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
import json
|
||||
|
||||
from ..config.database import get_db
|
||||
from ..config.logging_config import get_logger
|
||||
from ..models.page_content import PageContent, PageType
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/home", tags=["home"])
|
||||
|
||||
|
||||
def serialize_page_content(content: PageContent) -> dict:
|
||||
"""Serialize PageContent model to dictionary"""
|
||||
return {
|
||||
"id": content.id,
|
||||
"page_type": content.page_type.value,
|
||||
"title": content.title,
|
||||
"subtitle": content.subtitle,
|
||||
"description": content.description,
|
||||
"content": content.content,
|
||||
"meta_title": content.meta_title,
|
||||
"meta_description": content.meta_description,
|
||||
"meta_keywords": content.meta_keywords,
|
||||
"og_title": content.og_title,
|
||||
"og_description": content.og_description,
|
||||
"og_image": content.og_image,
|
||||
"canonical_url": content.canonical_url,
|
||||
"hero_title": content.hero_title,
|
||||
"hero_subtitle": content.hero_subtitle,
|
||||
"hero_image": content.hero_image,
|
||||
"amenities_section_title": content.amenities_section_title,
|
||||
"amenities_section_subtitle": content.amenities_section_subtitle,
|
||||
"amenities": json.loads(content.amenities) if content.amenities else None,
|
||||
"testimonials_section_title": content.testimonials_section_title,
|
||||
"testimonials_section_subtitle": content.testimonials_section_subtitle,
|
||||
"testimonials": json.loads(content.testimonials) if content.testimonials else None,
|
||||
"gallery_section_title": content.gallery_section_title,
|
||||
"gallery_section_subtitle": content.gallery_section_subtitle,
|
||||
"gallery_images": json.loads(content.gallery_images) if content.gallery_images else None,
|
||||
"luxury_section_title": content.luxury_section_title,
|
||||
"luxury_section_subtitle": content.luxury_section_subtitle,
|
||||
"luxury_section_image": content.luxury_section_image,
|
||||
"luxury_features": json.loads(content.luxury_features) if content.luxury_features else None,
|
||||
"luxury_gallery_section_title": content.luxury_gallery_section_title,
|
||||
"luxury_gallery_section_subtitle": content.luxury_gallery_section_subtitle,
|
||||
"luxury_gallery": json.loads(content.luxury_gallery) if content.luxury_gallery else None,
|
||||
"luxury_testimonials_section_title": content.luxury_testimonials_section_title,
|
||||
"luxury_testimonials_section_subtitle": content.luxury_testimonials_section_subtitle,
|
||||
"luxury_testimonials": json.loads(content.luxury_testimonials) if content.luxury_testimonials else None,
|
||||
"about_preview_title": content.about_preview_title,
|
||||
"about_preview_subtitle": content.about_preview_subtitle,
|
||||
"about_preview_content": content.about_preview_content,
|
||||
"about_preview_image": content.about_preview_image,
|
||||
"stats": json.loads(content.stats) if content.stats else None,
|
||||
"luxury_services_section_title": content.luxury_services_section_title,
|
||||
"luxury_services_section_subtitle": content.luxury_services_section_subtitle,
|
||||
"luxury_services": json.loads(content.luxury_services) if content.luxury_services else None,
|
||||
"luxury_experiences_section_title": content.luxury_experiences_section_title,
|
||||
"luxury_experiences_section_subtitle": content.luxury_experiences_section_subtitle,
|
||||
"luxury_experiences": json.loads(content.luxury_experiences) if content.luxury_experiences else None,
|
||||
"awards_section_title": content.awards_section_title,
|
||||
"awards_section_subtitle": content.awards_section_subtitle,
|
||||
"awards": json.loads(content.awards) if content.awards else None,
|
||||
"cta_title": content.cta_title,
|
||||
"cta_subtitle": content.cta_subtitle,
|
||||
"cta_button_text": content.cta_button_text,
|
||||
"cta_button_link": content.cta_button_link,
|
||||
"cta_image": content.cta_image,
|
||||
"partners_section_title": content.partners_section_title,
|
||||
"partners_section_subtitle": content.partners_section_subtitle,
|
||||
"partners": json.loads(content.partners) if content.partners else None,
|
||||
"is_active": content.is_active,
|
||||
"created_at": content.created_at.isoformat() if content.created_at else None,
|
||||
"updated_at": content.updated_at.isoformat() if content.updated_at else None,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_home_content(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get homepage content"""
|
||||
try:
|
||||
content = db.query(PageContent).filter(PageContent.page_type == PageType.HOME).first()
|
||||
|
||||
if not content:
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": None
|
||||
}
|
||||
}
|
||||
|
||||
content_dict = serialize_page_content(content)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"page_content": content_dict
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching home content: {str(e)}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Error fetching home content: {str(e)}"
|
||||
)
|
||||
|
||||
@@ -87,11 +87,38 @@ async def create_invoice(
|
||||
if not booking_id:
|
||||
raise HTTPException(status_code=400, detail="booking_id is required")
|
||||
|
||||
# Ensure booking_id is an integer
|
||||
try:
|
||||
booking_id = int(booking_id)
|
||||
except (ValueError, TypeError):
|
||||
raise HTTPException(status_code=400, detail="booking_id must be a valid integer")
|
||||
|
||||
# Check if booking exists
|
||||
booking = db.query(Booking).filter(Booking.id == booking_id).first()
|
||||
if not booking:
|
||||
raise HTTPException(status_code=404, detail="Booking not found")
|
||||
|
||||
# Prepare invoice kwargs
|
||||
invoice_kwargs = {
|
||||
"company_name": invoice_data.get("company_name"),
|
||||
"company_address": invoice_data.get("company_address"),
|
||||
"company_phone": invoice_data.get("company_phone"),
|
||||
"company_email": invoice_data.get("company_email"),
|
||||
"company_tax_id": invoice_data.get("company_tax_id"),
|
||||
"company_logo_url": invoice_data.get("company_logo_url"),
|
||||
"customer_tax_id": invoice_data.get("customer_tax_id"),
|
||||
"notes": invoice_data.get("notes"),
|
||||
"terms_and_conditions": invoice_data.get("terms_and_conditions"),
|
||||
"payment_instructions": invoice_data.get("payment_instructions"),
|
||||
}
|
||||
|
||||
# Add promotion code to invoice notes if present in booking
|
||||
invoice_notes = invoice_kwargs.get("notes", "")
|
||||
if booking.promotion_code:
|
||||
promotion_note = f"Promotion Code: {booking.promotion_code}"
|
||||
invoice_notes = f"{promotion_note}\n{invoice_notes}".strip() if invoice_notes else promotion_note
|
||||
invoice_kwargs["notes"] = invoice_notes
|
||||
|
||||
# Create invoice
|
||||
invoice = InvoiceService.create_invoice_from_booking(
|
||||
booking_id=booking_id,
|
||||
@@ -100,16 +127,7 @@ async def create_invoice(
|
||||
tax_rate=invoice_data.get("tax_rate", 0.0),
|
||||
discount_amount=invoice_data.get("discount_amount", 0.0),
|
||||
due_days=invoice_data.get("due_days", 30),
|
||||
company_name=invoice_data.get("company_name"),
|
||||
company_address=invoice_data.get("company_address"),
|
||||
company_phone=invoice_data.get("company_phone"),
|
||||
company_email=invoice_data.get("company_email"),
|
||||
company_tax_id=invoice_data.get("company_tax_id"),
|
||||
company_logo_url=invoice_data.get("company_logo_url"),
|
||||
customer_tax_id=invoice_data.get("customer_tax_id"),
|
||||
notes=invoice_data.get("notes"),
|
||||
terms_and_conditions=invoice_data.get("terms_and_conditions"),
|
||||
payment_instructions=invoice_data.get("payment_instructions"),
|
||||
**invoice_kwargs
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Request, UploadFile, File
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os
|
||||
import aiofiles
|
||||
import uuid
|
||||
|
||||
from ..config.database import get_db
|
||||
from ..config.logging_config import get_logger
|
||||
from ..middleware.auth import get_current_user, authorize_roles
|
||||
from ..models.user import User
|
||||
from ..models.page_content import PageContent, PageType
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/page-content", tags=["page-content"])
|
||||
|
||||
|
||||
@@ -40,12 +47,60 @@ async def get_all_page_contents(
|
||||
"social_links": json.loads(content.social_links) if content.social_links else None,
|
||||
"footer_links": json.loads(content.footer_links) if content.footer_links else None,
|
||||
"badges": json.loads(content.badges) if content.badges else None,
|
||||
"copyright_text": content.copyright_text,
|
||||
"hero_title": content.hero_title,
|
||||
"hero_subtitle": content.hero_subtitle,
|
||||
"hero_image": content.hero_image,
|
||||
"story_content": content.story_content,
|
||||
"values": json.loads(content.values) if content.values else None,
|
||||
"features": json.loads(content.features) if content.features else None,
|
||||
"about_hero_image": content.about_hero_image,
|
||||
"mission": content.mission,
|
||||
"vision": content.vision,
|
||||
"team": json.loads(content.team) if content.team else None,
|
||||
"timeline": json.loads(content.timeline) if content.timeline else None,
|
||||
"achievements": json.loads(content.achievements) if content.achievements else None,
|
||||
"amenities_section_title": content.amenities_section_title,
|
||||
"amenities_section_subtitle": content.amenities_section_subtitle,
|
||||
"amenities": json.loads(content.amenities) if content.amenities else None,
|
||||
"testimonials_section_title": content.testimonials_section_title,
|
||||
"testimonials_section_subtitle": content.testimonials_section_subtitle,
|
||||
"testimonials": json.loads(content.testimonials) if content.testimonials else None,
|
||||
"gallery_section_title": content.gallery_section_title,
|
||||
"gallery_section_subtitle": content.gallery_section_subtitle,
|
||||
"gallery_images": json.loads(content.gallery_images) if content.gallery_images else None,
|
||||
"luxury_section_title": content.luxury_section_title,
|
||||
"luxury_section_subtitle": content.luxury_section_subtitle,
|
||||
"luxury_section_image": content.luxury_section_image,
|
||||
"luxury_features": json.loads(content.luxury_features) if content.luxury_features else None,
|
||||
"luxury_gallery_section_title": content.luxury_gallery_section_title,
|
||||
"luxury_gallery_section_subtitle": content.luxury_gallery_section_subtitle,
|
||||
"luxury_gallery": json.loads(content.luxury_gallery) if content.luxury_gallery else None,
|
||||
"luxury_testimonials_section_title": content.luxury_testimonials_section_title,
|
||||
"luxury_testimonials_section_subtitle": content.luxury_testimonials_section_subtitle,
|
||||
"luxury_testimonials": json.loads(content.luxury_testimonials) if content.luxury_testimonials else None,
|
||||
"about_preview_title": content.about_preview_title,
|
||||
"about_preview_subtitle": content.about_preview_subtitle,
|
||||
"about_preview_content": content.about_preview_content,
|
||||
"about_preview_image": content.about_preview_image,
|
||||
"stats": json.loads(content.stats) if content.stats else None,
|
||||
"luxury_services_section_title": content.luxury_services_section_title,
|
||||
"luxury_services_section_subtitle": content.luxury_services_section_subtitle,
|
||||
"luxury_services": json.loads(content.luxury_services) if content.luxury_services else None,
|
||||
"luxury_experiences_section_title": content.luxury_experiences_section_title,
|
||||
"luxury_experiences_section_subtitle": content.luxury_experiences_section_subtitle,
|
||||
"luxury_experiences": json.loads(content.luxury_experiences) if content.luxury_experiences else None,
|
||||
"awards_section_title": content.awards_section_title,
|
||||
"awards_section_subtitle": content.awards_section_subtitle,
|
||||
"awards": json.loads(content.awards) if content.awards else None,
|
||||
"cta_title": content.cta_title,
|
||||
"cta_subtitle": content.cta_subtitle,
|
||||
"cta_button_text": content.cta_button_text,
|
||||
"cta_button_link": content.cta_button_link,
|
||||
"cta_image": content.cta_image,
|
||||
"partners_section_title": content.partners_section_title,
|
||||
"partners_section_subtitle": content.partners_section_subtitle,
|
||||
"partners": json.loads(content.partners) if content.partners else None,
|
||||
"is_active": content.is_active,
|
||||
"created_at": content.created_at.isoformat() if content.created_at else None,
|
||||
"updated_at": content.updated_at.isoformat() if content.updated_at else None,
|
||||
@@ -65,6 +120,104 @@ async def get_all_page_contents(
|
||||
)
|
||||
|
||||
|
||||
def get_base_url(request: Request) -> str:
|
||||
"""Get base URL for image normalization"""
|
||||
return os.getenv("SERVER_URL") or f"http://{request.headers.get('host', 'localhost:8000')}"
|
||||
|
||||
|
||||
def normalize_image_url(image_url: str, base_url: str) -> str:
|
||||
"""Normalize image URL to absolute URL"""
|
||||
if not image_url:
|
||||
return image_url
|
||||
if image_url.startswith('http://') or image_url.startswith('https://'):
|
||||
return image_url
|
||||
if image_url.startswith('/'):
|
||||
return f"{base_url}{image_url}"
|
||||
return f"{base_url}/{image_url}"
|
||||
|
||||
|
||||
@router.post("/upload", dependencies=[Depends(authorize_roles("admin"))])
|
||||
async def upload_page_content_image(
|
||||
request: Request,
|
||||
image: UploadFile = File(...),
|
||||
current_user: User = Depends(authorize_roles("admin")),
|
||||
):
|
||||
"""Upload page content image (Admin only)"""
|
||||
try:
|
||||
logger.info(f"Upload request received: filename={image.filename}, content_type={image.content_type}")
|
||||
|
||||
# Validate file exists
|
||||
if not image:
|
||||
logger.error("No file provided in upload request")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="No file provided"
|
||||
)
|
||||
|
||||
# Validate file type
|
||||
if not image.content_type or not image.content_type.startswith('image/'):
|
||||
logger.error(f"Invalid file type: {image.content_type}")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"File must be an image. Received: {image.content_type}"
|
||||
)
|
||||
|
||||
# Validate filename
|
||||
if not image.filename:
|
||||
logger.error("No filename provided in upload request")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Filename is required"
|
||||
)
|
||||
|
||||
# Create uploads directory
|
||||
upload_dir = Path(__file__).parent.parent.parent / "uploads" / "page-content"
|
||||
upload_dir.mkdir(parents=True, exist_ok=True)
|
||||
logger.info(f"Upload directory: {upload_dir}")
|
||||
|
||||
# Generate filename
|
||||
ext = Path(image.filename).suffix or '.jpg'
|
||||
filename = f"page-content-{uuid.uuid4()}{ext}"
|
||||
file_path = upload_dir / filename
|
||||
|
||||
# Save file
|
||||
async with aiofiles.open(file_path, 'wb') as f:
|
||||
content = await image.read()
|
||||
if not content:
|
||||
logger.error("Empty file uploaded")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="File is empty"
|
||||
)
|
||||
await f.write(content)
|
||||
logger.info(f"File saved successfully: {file_path}, size: {len(content)} bytes")
|
||||
|
||||
# Return the image URL
|
||||
image_url = f"/uploads/page-content/{filename}"
|
||||
base_url = get_base_url(request)
|
||||
full_url = normalize_image_url(image_url, base_url)
|
||||
|
||||
logger.info(f"Upload successful: {image_url}")
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": "Image uploaded successfully",
|
||||
"data": {
|
||||
"image_url": image_url,
|
||||
"full_url": full_url
|
||||
}
|
||||
}
|
||||
except HTTPException as e:
|
||||
logger.error(f"HTTPException in upload: {e.detail}")
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error(f"Unexpected error uploading image: {str(e)}", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Error uploading image: {str(e)}"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{page_type}")
|
||||
async def get_page_content(
|
||||
page_type: PageType,
|
||||
@@ -102,12 +255,60 @@ async def get_page_content(
|
||||
"social_links": json.loads(content.social_links) if content.social_links else None,
|
||||
"footer_links": json.loads(content.footer_links) if content.footer_links else None,
|
||||
"badges": json.loads(content.badges) if content.badges else None,
|
||||
"copyright_text": content.copyright_text,
|
||||
"hero_title": content.hero_title,
|
||||
"hero_subtitle": content.hero_subtitle,
|
||||
"hero_image": content.hero_image,
|
||||
"story_content": content.story_content,
|
||||
"values": json.loads(content.values) if content.values else None,
|
||||
"features": json.loads(content.features) if content.features else None,
|
||||
"about_hero_image": content.about_hero_image,
|
||||
"mission": content.mission,
|
||||
"vision": content.vision,
|
||||
"team": json.loads(content.team) if content.team else None,
|
||||
"timeline": json.loads(content.timeline) if content.timeline else None,
|
||||
"achievements": json.loads(content.achievements) if content.achievements else None,
|
||||
"amenities_section_title": content.amenities_section_title,
|
||||
"amenities_section_subtitle": content.amenities_section_subtitle,
|
||||
"amenities": json.loads(content.amenities) if content.amenities else None,
|
||||
"testimonials_section_title": content.testimonials_section_title,
|
||||
"testimonials_section_subtitle": content.testimonials_section_subtitle,
|
||||
"testimonials": json.loads(content.testimonials) if content.testimonials else None,
|
||||
"gallery_section_title": content.gallery_section_title,
|
||||
"gallery_section_subtitle": content.gallery_section_subtitle,
|
||||
"gallery_images": json.loads(content.gallery_images) if content.gallery_images else None,
|
||||
"luxury_section_title": content.luxury_section_title,
|
||||
"luxury_section_subtitle": content.luxury_section_subtitle,
|
||||
"luxury_section_image": content.luxury_section_image,
|
||||
"luxury_features": json.loads(content.luxury_features) if content.luxury_features else None,
|
||||
"luxury_gallery_section_title": content.luxury_gallery_section_title,
|
||||
"luxury_gallery_section_subtitle": content.luxury_gallery_section_subtitle,
|
||||
"luxury_gallery": json.loads(content.luxury_gallery) if content.luxury_gallery else None,
|
||||
"luxury_testimonials_section_title": content.luxury_testimonials_section_title,
|
||||
"luxury_testimonials_section_subtitle": content.luxury_testimonials_section_subtitle,
|
||||
"luxury_testimonials": json.loads(content.luxury_testimonials) if content.luxury_testimonials else None,
|
||||
"about_preview_title": content.about_preview_title,
|
||||
"about_preview_subtitle": content.about_preview_subtitle,
|
||||
"about_preview_content": content.about_preview_content,
|
||||
"about_preview_image": content.about_preview_image,
|
||||
"stats": json.loads(content.stats) if content.stats else None,
|
||||
"luxury_services_section_title": content.luxury_services_section_title,
|
||||
"luxury_services_section_subtitle": content.luxury_services_section_subtitle,
|
||||
"luxury_services": json.loads(content.luxury_services) if content.luxury_services else None,
|
||||
"luxury_experiences_section_title": content.luxury_experiences_section_title,
|
||||
"luxury_experiences_section_subtitle": content.luxury_experiences_section_subtitle,
|
||||
"luxury_experiences": json.loads(content.luxury_experiences) if content.luxury_experiences else None,
|
||||
"awards_section_title": content.awards_section_title,
|
||||
"awards_section_subtitle": content.awards_section_subtitle,
|
||||
"awards": json.loads(content.awards) if content.awards else None,
|
||||
"cta_title": content.cta_title,
|
||||
"cta_subtitle": content.cta_subtitle,
|
||||
"cta_button_text": content.cta_button_text,
|
||||
"cta_button_link": content.cta_button_link,
|
||||
"cta_image": content.cta_image,
|
||||
"partners_section_title": content.partners_section_title,
|
||||
"partners_section_subtitle": content.partners_section_subtitle,
|
||||
"partners": json.loads(content.partners) if content.partners else None,
|
||||
"is_active": content.is_active,
|
||||
"created_at": content.created_at.isoformat() if content.created_at else None,
|
||||
"updated_at": content.updated_at.isoformat() if content.updated_at else None,
|
||||
@@ -151,6 +352,12 @@ async def create_or_update_page_content(
|
||||
story_content: Optional[str] = None,
|
||||
values: Optional[str] = None,
|
||||
features: Optional[str] = None,
|
||||
about_hero_image: Optional[str] = None,
|
||||
mission: Optional[str] = None,
|
||||
vision: Optional[str] = None,
|
||||
team: Optional[str] = None,
|
||||
timeline: Optional[str] = None,
|
||||
achievements: Optional[str] = None,
|
||||
is_active: bool = True,
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
@@ -263,6 +470,18 @@ async def create_or_update_page_content(
|
||||
existing_content.values = values
|
||||
if features is not None:
|
||||
existing_content.features = features
|
||||
if about_hero_image is not None:
|
||||
existing_content.about_hero_image = about_hero_image
|
||||
if mission is not None:
|
||||
existing_content.mission = mission
|
||||
if vision is not None:
|
||||
existing_content.vision = vision
|
||||
if team is not None:
|
||||
existing_content.team = team
|
||||
if timeline is not None:
|
||||
existing_content.timeline = timeline
|
||||
if achievements is not None:
|
||||
existing_content.achievements = achievements
|
||||
if is_active is not None:
|
||||
existing_content.is_active = is_active
|
||||
|
||||
@@ -308,6 +527,12 @@ async def create_or_update_page_content(
|
||||
story_content=story_content,
|
||||
values=values,
|
||||
features=features,
|
||||
about_hero_image=about_hero_image,
|
||||
mission=mission,
|
||||
vision=vision,
|
||||
team=team,
|
||||
timeline=timeline,
|
||||
achievements=achievements,
|
||||
is_active=is_active,
|
||||
)
|
||||
|
||||
@@ -362,7 +587,10 @@ async def update_page_content(
|
||||
for key, value in page_data.items():
|
||||
if hasattr(existing_content, key):
|
||||
# Handle JSON fields - convert dict/list to JSON string
|
||||
if key in ["contact_info", "social_links", "footer_links", "badges", "values", "features"] and value is not None:
|
||||
if key in ["contact_info", "social_links", "footer_links", "badges", "values", "features",
|
||||
"amenities", "testimonials", "gallery_images", "stats", "luxury_features",
|
||||
"luxury_gallery", "luxury_testimonials", "luxury_services", "luxury_experiences",
|
||||
"awards", "partners", "team", "timeline", "achievements"] and value is not None:
|
||||
if isinstance(value, str):
|
||||
# Already a string, validate it's valid JSON
|
||||
try:
|
||||
@@ -403,12 +631,60 @@ async def update_page_content(
|
||||
"social_links": json.loads(existing_content.social_links) if existing_content.social_links else None,
|
||||
"footer_links": json.loads(existing_content.footer_links) if existing_content.footer_links else None,
|
||||
"badges": json.loads(existing_content.badges) if existing_content.badges else None,
|
||||
"copyright_text": existing_content.copyright_text,
|
||||
"hero_title": existing_content.hero_title,
|
||||
"hero_subtitle": existing_content.hero_subtitle,
|
||||
"hero_image": existing_content.hero_image,
|
||||
"story_content": existing_content.story_content,
|
||||
"values": json.loads(existing_content.values) if existing_content.values else None,
|
||||
"features": json.loads(existing_content.features) if existing_content.features else None,
|
||||
"about_hero_image": existing_content.about_hero_image,
|
||||
"mission": existing_content.mission,
|
||||
"vision": existing_content.vision,
|
||||
"team": json.loads(existing_content.team) if existing_content.team else None,
|
||||
"timeline": json.loads(existing_content.timeline) if existing_content.timeline else None,
|
||||
"achievements": json.loads(existing_content.achievements) if existing_content.achievements else None,
|
||||
"amenities_section_title": existing_content.amenities_section_title,
|
||||
"amenities_section_subtitle": existing_content.amenities_section_subtitle,
|
||||
"amenities": json.loads(existing_content.amenities) if existing_content.amenities else None,
|
||||
"testimonials_section_title": existing_content.testimonials_section_title,
|
||||
"testimonials_section_subtitle": existing_content.testimonials_section_subtitle,
|
||||
"testimonials": json.loads(existing_content.testimonials) if existing_content.testimonials else None,
|
||||
"gallery_section_title": existing_content.gallery_section_title,
|
||||
"gallery_section_subtitle": existing_content.gallery_section_subtitle,
|
||||
"gallery_images": json.loads(existing_content.gallery_images) if existing_content.gallery_images else None,
|
||||
"luxury_section_title": existing_content.luxury_section_title,
|
||||
"luxury_section_subtitle": existing_content.luxury_section_subtitle,
|
||||
"luxury_section_image": existing_content.luxury_section_image,
|
||||
"luxury_features": json.loads(existing_content.luxury_features) if existing_content.luxury_features else None,
|
||||
"luxury_gallery_section_title": existing_content.luxury_gallery_section_title,
|
||||
"luxury_gallery_section_subtitle": existing_content.luxury_gallery_section_subtitle,
|
||||
"luxury_gallery": json.loads(existing_content.luxury_gallery) if existing_content.luxury_gallery else None,
|
||||
"luxury_testimonials_section_title": existing_content.luxury_testimonials_section_title,
|
||||
"luxury_testimonials_section_subtitle": existing_content.luxury_testimonials_section_subtitle,
|
||||
"luxury_testimonials": json.loads(existing_content.luxury_testimonials) if existing_content.luxury_testimonials else None,
|
||||
"about_preview_title": existing_content.about_preview_title,
|
||||
"about_preview_subtitle": existing_content.about_preview_subtitle,
|
||||
"about_preview_content": existing_content.about_preview_content,
|
||||
"about_preview_image": existing_content.about_preview_image,
|
||||
"stats": json.loads(existing_content.stats) if existing_content.stats else None,
|
||||
"luxury_services_section_title": existing_content.luxury_services_section_title,
|
||||
"luxury_services_section_subtitle": existing_content.luxury_services_section_subtitle,
|
||||
"luxury_services": json.loads(existing_content.luxury_services) if existing_content.luxury_services else None,
|
||||
"luxury_experiences_section_title": existing_content.luxury_experiences_section_title,
|
||||
"luxury_experiences_section_subtitle": existing_content.luxury_experiences_section_subtitle,
|
||||
"luxury_experiences": json.loads(existing_content.luxury_experiences) if existing_content.luxury_experiences else None,
|
||||
"awards_section_title": existing_content.awards_section_title,
|
||||
"awards_section_subtitle": existing_content.awards_section_subtitle,
|
||||
"awards": json.loads(existing_content.awards) if existing_content.awards else None,
|
||||
"cta_title": existing_content.cta_title,
|
||||
"cta_subtitle": existing_content.cta_subtitle,
|
||||
"cta_button_text": existing_content.cta_button_text,
|
||||
"cta_button_link": existing_content.cta_button_link,
|
||||
"cta_image": existing_content.cta_image,
|
||||
"partners_section_title": existing_content.partners_section_title,
|
||||
"partners_section_subtitle": existing_content.partners_section_subtitle,
|
||||
"partners": json.loads(existing_content.partners) if existing_content.partners else None,
|
||||
"is_active": existing_content.is_active,
|
||||
"updated_at": existing_content.updated_at.isoformat() if existing_content.updated_at else None,
|
||||
}
|
||||
|
||||
@@ -694,18 +694,24 @@ async def upload_room_images(
|
||||
image_urls = []
|
||||
for image in images:
|
||||
# Validate file type
|
||||
if not image.content_type.startswith('image/'):
|
||||
if not image.content_type or not image.content_type.startswith('image/'):
|
||||
continue
|
||||
|
||||
# Validate filename
|
||||
if not image.filename:
|
||||
continue
|
||||
|
||||
# Generate filename
|
||||
import uuid
|
||||
ext = Path(image.filename).suffix
|
||||
ext = Path(image.filename).suffix or '.jpg'
|
||||
filename = f"room-{uuid.uuid4()}{ext}"
|
||||
file_path = upload_dir / filename
|
||||
|
||||
# Save file
|
||||
async with aiofiles.open(file_path, 'wb') as f:
|
||||
content = await image.read()
|
||||
if not content:
|
||||
continue
|
||||
await f.write(content)
|
||||
|
||||
image_urls.append(f"/uploads/rooms/{filename}")
|
||||
@@ -717,6 +723,7 @@ async def upload_room_images(
|
||||
db.commit()
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": "Images uploaded successfully",
|
||||
"data": {"images": updated_images}
|
||||
|
||||
@@ -1127,6 +1127,7 @@ async def upload_company_logo(
|
||||
full_url = normalize_image_url(image_url, base_url)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": "Logo uploaded successfully",
|
||||
"data": {
|
||||
@@ -1235,6 +1236,7 @@ async def upload_company_favicon(
|
||||
full_url = normalize_image_url(image_url, base_url)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": "Favicon uploaded successfully",
|
||||
"data": {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -146,16 +146,28 @@ class AuthService:
|
||||
|
||||
async def login(self, db: Session, email: str, password: str, remember_me: bool = False, mfa_token: str = None) -> dict:
|
||||
"""Login user with optional MFA verification"""
|
||||
# Normalize email (lowercase and strip whitespace)
|
||||
email = email.lower().strip() if email else ""
|
||||
if not email:
|
||||
raise ValueError("Invalid email or password")
|
||||
|
||||
# Find user with role and password
|
||||
user = db.query(User).filter(User.email == email).first()
|
||||
if not user:
|
||||
logger.warning(f"Login attempt with non-existent email: {email}")
|
||||
raise ValueError("Invalid email or password")
|
||||
|
||||
# Check if user is active
|
||||
if not user.is_active:
|
||||
logger.warning(f"Login attempt for inactive user: {email}")
|
||||
raise ValueError("Account is disabled. Please contact support.")
|
||||
|
||||
# Load role
|
||||
user.role = db.query(Role).filter(Role.id == user.role_id).first()
|
||||
|
||||
# Check password
|
||||
if not self.verify_password(password, user.password):
|
||||
logger.warning(f"Login attempt with invalid password for user: {email}")
|
||||
raise ValueError("Invalid email or password")
|
||||
|
||||
# Check if MFA is enabled
|
||||
|
||||
@@ -87,10 +87,20 @@ class InvoiceService:
|
||||
|
||||
# Calculate amounts - subtotal will be recalculated after adding items
|
||||
# Initial subtotal is booking total (room + services) or invoice_amount if specified
|
||||
booking_total = float(booking.total_price)
|
||||
if invoice_amount is not None:
|
||||
subtotal = float(invoice_amount)
|
||||
# For partial invoices, ensure discount is proportional
|
||||
# If discount_amount seems too large (greater than subtotal), recalculate proportionally
|
||||
if invoice_amount < booking_total and discount_amount > 0:
|
||||
# Check if discount seems disproportionate (greater than 50% of subtotal suggests it's the full discount)
|
||||
if discount_amount > subtotal * 0.5:
|
||||
# Recalculate proportionally from booking's original discount
|
||||
proportion = float(invoice_amount) / booking_total
|
||||
original_discount = float(booking.discount_amount) if booking.discount_amount else discount_amount
|
||||
discount_amount = original_discount * proportion
|
||||
else:
|
||||
subtotal = float(booking.total_price)
|
||||
subtotal = booking_total
|
||||
|
||||
# Calculate tax and total amounts
|
||||
tax_amount = (subtotal - discount_amount) * (tax_rate / 100)
|
||||
@@ -388,6 +398,14 @@ class InvoiceService:
|
||||
@staticmethod
|
||||
def invoice_to_dict(invoice: Invoice) -> Dict[str, Any]:
|
||||
"""Convert invoice model to dictionary"""
|
||||
# Extract promotion code from notes if present
|
||||
promotion_code = None
|
||||
if invoice.notes and "Promotion Code:" in invoice.notes:
|
||||
try:
|
||||
promotion_code = invoice.notes.split("Promotion Code:")[1].split("\n")[0].strip()
|
||||
except:
|
||||
pass
|
||||
|
||||
return {
|
||||
"id": invoice.id,
|
||||
"invoice_number": invoice.invoice_number,
|
||||
@@ -419,6 +437,7 @@ class InvoiceService:
|
||||
"terms_and_conditions": invoice.terms_and_conditions,
|
||||
"payment_instructions": invoice.payment_instructions,
|
||||
"is_proforma": invoice.is_proforma if hasattr(invoice, 'is_proforma') else False,
|
||||
"promotion_code": promotion_code,
|
||||
"items": [
|
||||
{
|
||||
"id": item.id,
|
||||
|
||||
@@ -505,10 +505,36 @@ class PayPalService:
|
||||
except Exception as email_error:
|
||||
logger.error(f"Failed to send booking confirmation email: {str(email_error)}")
|
||||
|
||||
# Send invoice email if payment is completed and invoice is now paid
|
||||
from ..utils.mailer import send_email
|
||||
from ..services.invoice_service import InvoiceService
|
||||
from ..routes.booking_routes import _generate_invoice_email_html
|
||||
|
||||
# Load user for email
|
||||
from ..models.user import User
|
||||
user = db.query(User).filter(User.id == booking.user_id).first()
|
||||
|
||||
for invoice in invoices:
|
||||
if invoice.status == InvoiceStatus.paid and invoice.balance_due <= 0:
|
||||
try:
|
||||
invoice_dict = InvoiceService.invoice_to_dict(invoice)
|
||||
invoice_html = _generate_invoice_email_html(invoice_dict, is_proforma=invoice.is_proforma)
|
||||
invoice_type = "Proforma Invoice" if invoice.is_proforma else "Invoice"
|
||||
if user:
|
||||
await send_email(
|
||||
to=user.email,
|
||||
subject=f"{invoice_type} {invoice.invoice_number} - Payment Confirmed",
|
||||
html=invoice_html
|
||||
)
|
||||
logger.info(f"{invoice_type} {invoice.invoice_number} sent to {user.email}")
|
||||
except Exception as email_error:
|
||||
logger.error(f"Failed to send invoice email: {str(email_error)}")
|
||||
|
||||
# Send invoice email if payment is completed and invoice is now paid
|
||||
from ..utils.mailer import send_email
|
||||
from ..services.invoice_service import InvoiceService
|
||||
from ..models.invoice import InvoiceStatus
|
||||
from ..routes.booking_routes import _generate_invoice_email_html
|
||||
|
||||
# Load user for email
|
||||
from ..models.user import User
|
||||
|
||||
@@ -404,6 +404,7 @@ class StripeService:
|
||||
# Send invoice email if payment is completed and invoice is now paid
|
||||
from ..utils.mailer import send_email
|
||||
from ..services.invoice_service import InvoiceService
|
||||
from ..routes.booking_routes import _generate_invoice_email_html
|
||||
|
||||
# Load user for email
|
||||
from ..models.user import User
|
||||
|
||||
Reference in New Issue
Block a user