Sharang Parnerkar
0c2e03f294
refactor(backend/api): extract Email Template services (Step 4 — file 10 of 18)
compliance/api/email_template_routes.py (823 LOC) -> 295 LOC thin routes
+ 402-line EmailTemplateService + 241-line EmailTemplateVersionService +
61-line schemas file.
Two-service split along natural responsibility seam:
email_template_service.py (402 LOC):
- Template type catalog (TEMPLATE_TYPES constant)
- Template CRUD (list, create, get)
- Stats, settings, send logs, initialization, default content
- Shared _template_to_dict / _version_to_dict / _render_template helpers
email_template_version_service.py (241 LOC):
- Version CRUD (create, list, get, update)
- Workflow transitions (submit, approve, reject, publish)
- Preview and test-send
TEMPLATE_TYPES, VALID_CATEGORIES, VALID_STATUSES re-exported from the
route module for any legacy consumers.
State-transition errors use ValidationError (-> HTTPException 400) to
preserve the original handler's 400 status for "Only draft/review
versions can be ..." checks, since the existing TestClient integration
tests (47 tests) assert status_code == 400.
Verified:
- 47/47 tests/test_email_template_routes.py pass
- OpenAPI 360/484 unchanged
- mypy compliance/ -> Success on 138 source files
- email_template_routes.py 823 -> 295 LOC
- Hard-cap violations: 9 -> 8
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 22:39:19 +02:00
..
2026-03-07 19:00:33 +01:00
2026-03-13 09:46:52 +01:00
2026-04-07 18:16:50 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 18:39:40 +02:00
2026-04-07 18:52:31 +02:00
2026-04-07 19:53:55 +02:00
2026-03-07 19:00:33 +01:00
2026-03-07 19:00:33 +01:00
2026-04-07 19:47:29 +02:00
2026-03-13 10:16:52 +01:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-03-07 17:07:43 +01:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-08 22:39:19 +02:00
2026-04-07 13:18:29 +02:00
2026-04-08 21:59:03 +02:00
2026-04-07 13:18:29 +02:00
2026-03-08 22:53:29 +01:00
2026-03-13 10:16:52 +01:00
2026-03-07 19:00:33 +01:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 13:18:29 +02:00
2026-03-09 17:48:02 +01:00
2026-04-07 13:18:29 +02:00
2026-03-02 12:46:11 +01:00
2026-04-07 13:18:29 +02:00
2026-04-07 18:06:27 +02:00
2026-04-07 20:03:16 +02:00
2026-04-07 13:18:29 +02:00
2026-04-07 19:58:02 +02:00
2026-03-07 14:12:34 +01:00
2026-04-07 19:42:17 +02:00
2026-04-07 13:18:29 +02:00
2026-03-07 19:00:33 +01:00
2026-04-07 19:50:40 +02:00
2026-03-09 20:01:27 +01:00