Repository navigation
Fix the reset form errors and translate the reset email - #1018
Merged
Merged
Conversation
- password_reset.jinja2 looped over `form.errors.items` without calling it, which Jinja2 rejects with "TypeError: 'builtin_function_or_method' object is not iterable", so posting an invalid email returned a 500 instead of showing the error. Call `items()` as password_reset_confirm.jinja2 already does. - password_reset_email.html and password_reset_subject.txt are rendered by the Jinja2 backend (it comes first in TEMPLATES and the files live under jinja2/), so wrap their text in _(), passing the address as %(email)s. Add both files to etc/babel.cfg so pybabel extracts them. - pt_BR and es_ES: add translations for the new msgids. - Add tests for the invalid-email error and for the reset email. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #1016.
Changes
password_reset.jinja2): the error loop usedform.errors.itemswithout calling it. Jinja2 raisesTypeError: 'builtin_function_or_method' object is not iterableon that, so posting an invalid email to/users/reset-password/returned a 500 instead of showing the error. Confirmed by rendering the snippet with Jinja2 and a dict of errors. Now callsitems(), aspassword_reset_confirm.jinja2already does.PasswordResetViewrenderspassword_reset_email.htmlandpassword_reset_subject.txtthroughrender_to_string. The Jinja2 backend comes first inTEMPLATESand the files live underjinja2/, so Jinja2 renders them with thei18nextension (newstyle gettext). Their text is now wrapped in_(), with the address passed as%(email)s.LocaleMiddlewarehas the request's language active when the email is sent, so the email goes out in the language the user browsed in.etc/babel.cfg: the existing pattern only matches**.jinja2, so I added the two files. Otherwisemake translate_<lang>would not extract their msgids and would mark them obsolete. Checked withpybabel extract -F ./etc/babel.cfg: it picks up the 5 new msgids.src/users/tests/test_reset_password.py): posting an invalid email returns 200 and shows "Enter a valid email address." A registered email gets one message with the subject and the reset link.The email body loses the leading indentation and the line breaks inside each paragraph, so each paragraph is one msgid.
Not changed: the email is plain text, but the address is still HTML-escaped by autoescape (e.g.
o'neil@…becomeso'neil@…). This was already the case before this PR.🤖 Generated with Claude Code