Add the experience service with sites through analytics/AI hooks, migrations through 0011, and phase docs/manifests marking the track complete. Co-authored-by: Cursor <cursoragent@cursor.com>
170 lines
4.8 KiB
Python
170 lines
4.8 KiB
Python
"""Forms / surveys / appointments command handlers — Phase 11.6."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.schemas.forms import (
|
|
AppointmentBookingRefCreate,
|
|
AppointmentBookingRefUpdate,
|
|
ExperienceAppointmentPageCreate,
|
|
ExperienceAppointmentPageUpdate,
|
|
ExperienceFormCreate,
|
|
ExperienceFormUpdate,
|
|
ExperienceSurveyCreate,
|
|
ExperienceSurveyUpdate,
|
|
FormSubmissionCreate,
|
|
FormSubmissionUpdate,
|
|
SurveyResponseCreate,
|
|
SurveyResponseUpdate,
|
|
)
|
|
from app.services.forms import ExperienceFormsService
|
|
from shared.security import CurrentUser
|
|
|
|
|
|
class FormsCommands:
|
|
def __init__(self, session: AsyncSession) -> None:
|
|
self.service = ExperienceFormsService(session)
|
|
|
|
async def create_form(
|
|
self,
|
|
tenant_id: UUID,
|
|
body: ExperienceFormCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.create_form(tenant_id, body, actor=actor)
|
|
|
|
async def update_form(
|
|
self,
|
|
tenant_id: UUID,
|
|
form_id: UUID,
|
|
body: ExperienceFormUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update_form(tenant_id, form_id, body, actor=actor)
|
|
|
|
async def soft_delete_form(
|
|
self, tenant_id: UUID, form_id: UUID, *, actor: CurrentUser | None
|
|
):
|
|
return await self.service.soft_delete_form(tenant_id, form_id, actor=actor)
|
|
|
|
async def create_submission(
|
|
self,
|
|
tenant_id: UUID,
|
|
body: FormSubmissionCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.create_submission(tenant_id, body, actor=actor)
|
|
|
|
async def update_submission(
|
|
self,
|
|
tenant_id: UUID,
|
|
submission_id: UUID,
|
|
body: FormSubmissionUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update_submission(
|
|
tenant_id, submission_id, body, actor=actor
|
|
)
|
|
|
|
async def create_survey(
|
|
self,
|
|
tenant_id: UUID,
|
|
body: ExperienceSurveyCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.create_survey(tenant_id, body, actor=actor)
|
|
|
|
async def update_survey(
|
|
self,
|
|
tenant_id: UUID,
|
|
survey_id: UUID,
|
|
body: ExperienceSurveyUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update_survey(
|
|
tenant_id, survey_id, body, actor=actor
|
|
)
|
|
|
|
async def soft_delete_survey(
|
|
self, tenant_id: UUID, survey_id: UUID, *, actor: CurrentUser | None
|
|
):
|
|
return await self.service.soft_delete_survey(tenant_id, survey_id, actor=actor)
|
|
|
|
async def create_survey_response(
|
|
self,
|
|
tenant_id: UUID,
|
|
body: SurveyResponseCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.create_survey_response(tenant_id, body, actor=actor)
|
|
|
|
async def update_survey_response(
|
|
self,
|
|
tenant_id: UUID,
|
|
response_id: UUID,
|
|
body: SurveyResponseUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update_survey_response(
|
|
tenant_id, response_id, body, actor=actor
|
|
)
|
|
|
|
async def create_appointment_page(
|
|
self,
|
|
tenant_id: UUID,
|
|
body: ExperienceAppointmentPageCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.create_appointment_page(tenant_id, body, actor=actor)
|
|
|
|
async def update_appointment_page(
|
|
self,
|
|
tenant_id: UUID,
|
|
page_id: UUID,
|
|
body: ExperienceAppointmentPageUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update_appointment_page(
|
|
tenant_id, page_id, body, actor=actor
|
|
)
|
|
|
|
async def soft_delete_appointment_page(
|
|
self, tenant_id: UUID, page_id: UUID, *, actor: CurrentUser | None
|
|
):
|
|
return await self.service.soft_delete_appointment_page(
|
|
tenant_id, page_id, actor=actor
|
|
)
|
|
|
|
async def create_booking_ref(
|
|
self,
|
|
tenant_id: UUID,
|
|
body: AppointmentBookingRefCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.create_booking_ref(tenant_id, body, actor=actor)
|
|
|
|
async def update_booking_ref(
|
|
self,
|
|
tenant_id: UUID,
|
|
booking_id: UUID,
|
|
body: AppointmentBookingRefUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update_booking_ref(
|
|
tenant_id, booking_id, body, actor=actor
|
|
)
|