docs: add comprehensive documentation for today's work

Technical Documentation:
- docs/development/architecture-fixes-2026-01.md: Complete guide to
  all architecture validation fixes (62 -> 0 errors)

User Guides:
- docs/guides/email-templates.md: How-to guide for vendors and admins
  to use the email template customization system

Implementation Docs:
- docs/implementation/password-reset-implementation.md: Technical
  documentation for the password reset feature
- Updated email-templates-architecture.md with EmailTemplateService
  documentation and related links

Bugfix:
- Fixed TemplateListItem Pydantic model to match service output
  (languages vs available_languages field name)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-03 19:07:09 +01:00
parent 5155ef7445
commit daec462847
7 changed files with 1234 additions and 4 deletions

View File

@@ -69,6 +69,59 @@ UNIQUE (vendor_id, template_code, language)
---
## Email Template Service
**File:** `app/services/email_template_service.py`
The `EmailTemplateService` encapsulates all email template business logic, keeping API endpoints clean and focused on request/response handling.
### Admin Methods
| Method | Description |
|--------|-------------|
| `list_platform_templates()` | List all platform templates grouped by code |
| `get_template_categories()` | Get list of template categories |
| `get_platform_template(code)` | Get template with all language versions |
| `update_platform_template(code, language, data)` | Update platform template content |
| `preview_template(code, language, variables)` | Generate preview with sample data |
| `get_template_logs(code, limit)` | Get email logs for template |
### Vendor Methods
| Method | Description |
|--------|-------------|
| `list_overridable_templates(vendor_id)` | List templates vendor can customize |
| `get_vendor_template(vendor_id, code, language)` | Get template (override or platform default) |
| `create_or_update_vendor_override(vendor_id, code, language, data)` | Save vendor customization |
| `delete_vendor_override(vendor_id, code, language)` | Revert to platform default |
| `preview_vendor_template(vendor_id, code, language, variables)` | Preview with vendor branding |
### Usage Example
```python
from app.services.email_template_service import EmailTemplateService
service = EmailTemplateService(db)
# List templates for admin
templates = service.list_platform_templates()
# Get vendor's view of a template
template_data = service.get_vendor_template(vendor_id, "order_confirmation", "fr")
# Create vendor override
service.create_or_update_vendor_override(
vendor_id=vendor.id,
code="order_confirmation",
language="fr",
subject="Votre commande {{ order_number }}",
body_html="<html>...</html>",
body_text="Plain text...",
)
```
---
## Email Service
**File:** `app/services/email_service.py`
@@ -372,7 +425,8 @@ db.commit()
│ │ ├── admin_pages.py (route added)
│ │ └── vendor_pages.py (route added)
│ ├── services/
│ │ ── email_service.py (enhanced)
│ │ ── email_service.py (enhanced)
│ │ └── email_template_service.py (new - business logic)
│ └── templates/
│ ├── admin/
│ │ ├── email-templates.html
@@ -394,3 +448,11 @@ db.commit()
└── vendor/js/
└── email-templates.js
```
---
## Related Documentation
- [Email Templates User Guide](../guides/email-templates.md) - How to use the email template system
- [Password Reset Implementation](./password-reset-implementation.md) - Password reset feature using email templates
- [Architecture Fixes (January 2026)](../development/architecture-fixes-2026-01.md) - Architecture validation fixes