Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate Flask-Security email subjects #1413

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Current (in progress)

- Translate Flask-Security email subjects [#1413](https://github.com/opendatateam/udata/pull/1413)

## 1.2.10 (2018-01-24)

- Markdown rendering is now the same between the back and the frontend. [#604](https://github.com/opendatateam/udata/issues/604)
Expand Down
15 changes: 10 additions & 5 deletions udata/patch_flask_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ def sendmail(subject, email, template, **context):
mail.send(subject, user, tpl, **context)


changeable.send_mail = sendmail.delay
confirmable.send_mail = sendmail.delay
passwordless.send_mail = sendmail.delay
recoverable.send_mail = sendmail.delay
registerable.send_mail = sendmail.delay
def sendmail_proxy(subject, email, template, **context):
"""Cast the lazy_gettext'ed subject to string before passing to Celery"""
sendmail.delay(subject[0].value, email, template, **context)


changeable.send_mail = sendmail_proxy
confirmable.send_mail = sendmail_proxy
passwordless.send_mail = sendmail_proxy
recoverable.send_mail = sendmail_proxy
registerable.send_mail = sendmail_proxy
11 changes: 11 additions & 0 deletions udata/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from kombu import Exchange, Queue

from udata.i18n import lazy_gettext as _


HOUR = 60 * 60


Expand Down Expand Up @@ -103,6 +106,14 @@ class Defaults(object):

SECURITY_EMAIL_SENDER = MAIL_DEFAULT_SENDER

SECURITY_EMAIL_SUBJECT_REGISTER = _('Welcome'),
SECURITY_EMAIL_SUBJECT_CONFIRM = _('Please confirm your email'),
SECURITY_EMAIL_SUBJECT_PASSWORDLESS = _('Login instructions'),
SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE = _('Your password has been reset'),
SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = _(
'Your password has been changed'),
SECURITY_EMAIL_SUBJECT_PASSWORD_RESET = _('Password reset instructions'),

# Flask WTF settings
CSRF_SESSION_KEY = 'Default uData csrf key'

Expand Down
Loading