Skip to content

[Pipeline B] Apply routes → services → repositories layering to templates (#640, part 2) - #653

Merged
marcvergees merged 1 commit into
fireform-core:development-approach-bfrom
abhishek-8081:issue-640-templates-layering
Aug 8, 2026
Merged

[Pipeline B] Apply routes → services → repositories layering to templates (#640, part 2)#653
marcvergees merged 1 commit into
fireform-core:development-approach-bfrom
abhishek-8081:issue-640-templates-layering

Conversation

@abhishek-8081

Copy link
Copy Markdown
Collaborator

Closes #640 (part 2 of 2 — part 1 was the forms layering in #652).

Applies the routes → services → repositories layering to the templates routes, same as part 1 did for forms.

  • New TemplateService (app/services/template.py) holds the logic — PDF field extraction, file saving, and the per-endpoint orchestration — matching the FormService/InputService pattern.
  • The two delete-dependency queries moved into repository functions (get_submissions_by_template, get_jobs_by_template).
  • templates.py routes are now thin: parse → service → return. HTTP concerns (404s, file checks) stay in the route.
  • Controller is unchanged — the service calls it, doesn't rewrite it.

Behavior is unchanged: 152 tests pass with only mock-location changes, no response-assertion changes. ruff check app/ is clean, and no direct DB queries remain in templates.py.

A couple of things I kept exactly as they were:

  • The delete cascade still commits once at the end (atomic — a partial failure deletes nothing), rather than committing per row.
  • The PDF field-extraction logic moved verbatim (same field ordering and type mapping).

Follow-up: _resolve_project_file / PROJECT_ROOT is now duplicated across forms.py, form.py, and template.py — worth a small consolidation issue later.

@marcvergees
marcvergees merged commit c07b7c7 into fireform-core:development-approach-b Aug 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants