Repository navigation
refactor(model): move OTP email rendering to campus.api (campus.model goes Flask-free at call time) - #983
Merged
Conversation
…lates The emailotp route was the only consumer of campus.model.emailotp.template, whose body()/html_body() call flask.render_template_string. Move the rendering (module + templates) into campus.api/emailotp_templates/ so campus.model is Flask-free even at call time - completing what #968 started lazily, in prep for the campus-model distribution split (#970 phase 3, see also #982 for the webauth-models remigration). campus.model.emailotp now holds only the EmailOTP record; the route imports the new module from its own package. Boundary-contract docstring drops the emailotp flask exception (rule 3 now has no exceptions), the model import-weight test asserts the template module is gone, and rendering coverage moves to tests/unit/api/test_emailotp_templates.py.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refators #970 (phase-3 prep — campus-model purity). Non-closing: #970 stays open as the phase tracker.
Change
campus.model.emailotp.template→campus.api.emailotp_templates(module +templates/moved viagit mv, 84%/100% renames). The emailotp route was the template's only consumer; it now imports the renderer from its own package, with module-levelimport flask(api is Flask territory — the #968 lazy-import arrangement is superseded, not preserved).campus.model.emailotpkeeps only theEmailOTPrecord;templateis dropped from its namespace.Why
campus.model must be Flask-free even at call time for the phase-3
campus-modeldistribution split: downstream apps install the data model without Flask-adjacent behavior. This completes what #968 started (lazy import) by relocating instead. Sister issue for the other model-purity move: #982 (webauth models remigration).Tests
tests/unit/model/test_import_weight.py: keeps the flask/jinja2-free import guard; adds a gone-check forcampus.model.emailotp.template(attribute-access pattern — the namespace-package trap from refactor(audit): move campus.common.http to campus.audit.http #976 applies); the render test moves out with its subject.tests/unit/api/test_emailotp_templates.py: subject/body/html_body render under an app context.Docs sweep
Ran the full docs/openapi sweep for
emailotp/template/model.emailotpreferences: every hit is feature-name prose ("Email OTP verification") or the openapi endpoint spec — zero module-path references exist in any doc, so no doc changes were needed for this move.Verification
Unit, contract, integration, and
ruff check .all green (contract'stest_api_emailotpexercises the moved rendering through the route).