feat: add hotel and vehicle option site modules
Add full support for hotel group and vehicle option site management features: - Define SQLAlchemy models and alembic migration for the new database tables - Add default sample content entries in content.py - Extend admin and public API routes to support the new modules - Update seed script to populate default hotel and vehicle data - Update all relevant documentation and test cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
from ..models import Campaign, CtaBanner, Destination, HeroSlide, MapImage, ThemeCard
|
||||
from ..models import Campaign, CtaBanner, Destination, HeroSlide, HotelGroup, MapImage, ThemeCard, VehicleOption
|
||||
from ..route_sections import route_section_dict, route_section_query
|
||||
from ..serializers import destination_dict, model_dict
|
||||
|
||||
@@ -11,12 +11,16 @@ def site_config(db: Session, active_only: bool, include_public_extras: bool = Tr
|
||||
map_stmt = select(MapImage).order_by(MapImage.createdAt.asc())
|
||||
theme_stmt = select(ThemeCard).order_by(ThemeCard.sortOrder.asc())
|
||||
cta_stmt = select(CtaBanner).order_by(CtaBanner.sortOrder.asc())
|
||||
hotel_stmt = select(HotelGroup).order_by(HotelGroup.sortOrder.asc())
|
||||
vehicle_stmt = select(VehicleOption).order_by(VehicleOption.sortOrder.asc())
|
||||
if active_only:
|
||||
hero_stmt = hero_stmt.where(HeroSlide.isActive.is_(True))
|
||||
destination_stmt = destination_stmt.where(Destination.isActive.is_(True))
|
||||
map_stmt = map_stmt.where(MapImage.isActive.is_(True))
|
||||
theme_stmt = theme_stmt.where(ThemeCard.isActive.is_(True))
|
||||
cta_stmt = cta_stmt.where(CtaBanner.isActive.is_(True))
|
||||
hotel_stmt = hotel_stmt.where(HotelGroup.isActive.is_(True))
|
||||
vehicle_stmt = vehicle_stmt.where(VehicleOption.isActive.is_(True))
|
||||
|
||||
hero_slides = db.scalars(hero_stmt).all()
|
||||
destinations = db.scalars(destination_stmt).all()
|
||||
@@ -37,4 +41,6 @@ def site_config(db: Session, active_only: bool, include_public_extras: bool = Tr
|
||||
route_sections = [section for section in route_sections if section.isActive]
|
||||
result["campaigns"] = [model_dict(item) for item in campaigns]
|
||||
result["routeSections"] = [route_section_dict(item, public=True) for item in route_sections]
|
||||
return result
|
||||
result["hotelGroups"] = [model_dict(item) for item in db.scalars(hotel_stmt).all()]
|
||||
result["vehicleOptions"] = [model_dict(item) for item in db.scalars(vehicle_stmt).all()]
|
||||
return result
|
||||
Reference in New Issue
Block a user