"""Privacy Policy Generator handler (template-based). Generates a comprehensive privacy policy document by filling a DOCX template with customer-specific information. Does not require LLM generation — uses pre-written policy sections with variable substitution. """ from __future__ import annotations import os from datetime import datetime from .base_handler import BaseServiceHandler class PrivacyPolicyHandler(BaseServiceHandler): SERVICE_SLUG = "privacy-policy" SERVICE_NAME = "Privacy Policy Generation" TEMPLATE_NAME = "privacy_policy_template.docx" REQUIRES_LLM = False async def process(self, order_data: dict) -> list[str]: work_dir = self._make_work_dir() order_number = order_data["name"] template_path = self._get_template_path() docx_filename = self._output_filename(order_number, "docx") docx_path = os.path.join(work_dir, docx_filename) # Extract intake data for template variables now = datetime.now() variables = { "order_number": order_number, "customer_name": order_data.get("customer_name", ""), "date": now.strftime("%B %d, %Y"), "effective_date": now.strftime("%B %d, %Y"), "service_name": self.SERVICE_NAME, # Company details "company_name": order_data.get("custom_company_legal_name", order_data.get("customer_name", "")), "company_website": order_data.get("custom_company_website", "[WEBSITE]"), "company_address": order_data.get("custom_company_address", "[ADDRESS]"), "company_email": order_data.get("custom_contact_email", "[EMAIL]"), "company_phone": order_data.get("custom_contact_phone", "[PHONE]"), # Privacy officer "privacy_officer_name": order_data.get("custom_privacy_officer", "[PRIVACY OFFICER]"), "privacy_officer_email": order_data.get("custom_privacy_officer_email", "[PRIVACY OFFICER EMAIL]"), # Data practices "data_collected": order_data.get("custom_data_types_collected", "name, email address, phone number, and other information you provide"), "data_purposes": order_data.get("custom_data_purposes", "providing our services, communicating with you, and improving our offerings"), "data_sharing": order_data.get("custom_data_sharing_parties", "service providers who assist in our operations"), "data_retention": order_data.get("custom_data_retention_period", "as long as necessary to fulfill the purposes described in this policy"), # Jurisdiction "state": order_data.get("custom_state", "California"), "applicable_laws": order_data.get("custom_applicable_privacy_laws", "CCPA/CPRA"), # Cookies "uses_cookies": order_data.get("custom_uses_cookies", "Yes"), "uses_analytics": order_data.get("custom_uses_analytics", "Yes"), "analytics_provider": order_data.get("custom_analytics_provider", "Google Analytics"), } self._fill_template(template_path, variables, docx_path) # Convert to PDF pdf_path = self._convert_to_pdf(docx_path) return [docx_path, pdf_path]