-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDX-9424 sending username confirmation email
- Loading branch information
1 parent
840d88b
commit 06cec22
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
ckanext-hdx_theme/ckanext/hdx_theme/helpers/ui_constants/onboarding/email_subjects.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CONSTANTS = { | ||
'EMAIL_CONFIRMATION': '''Verify your email address to confirm your HDX account''', | ||
'EMAIL_USERNAME_CONFIRMATION': '''Your new HDX account details''' | ||
} |
7 changes: 7 additions & 0 deletions
7
...eme/ckanext/hdx_theme/templates/email/content/onboarding/email_username_confirmation.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p>Dear {{ data.user_fullname }},</p> | ||
<p>Thank you for signing up to HDX.</p> | ||
<p>Your HDX account username is: <em>{{ data.username }}</em></p> | ||
<p>You can also use your email address to login.</p> | ||
<a href="{{ data.login_link }}" target="_blank" title="Login to HDX" class="button">Login to HDX</a> | ||
<p>Best wishes,</p> | ||
<p>The HDX Team</p> |
29 changes: 29 additions & 0 deletions
29
...xt-hdx_users/ckanext/hdx_users/controller_logic/onboarding_username_confirmation_logic.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
|
||
import ckan.plugins.toolkit as tk | ||
|
||
import ckanext.hdx_users.helpers.mailer as hdx_mailer | ||
|
||
from ckan.types import ActionResult | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
h = tk.h | ||
|
||
def send_username_confirmation_email(user_dict: ActionResult.UserShow) -> bool: | ||
subject = h.HDX_CONST('UI_CONSTANTS')['ONBOARDING']['EMAIL_SUBJECTS']['EMAIL_USERNAME_CONFIRMATION'] | ||
|
||
email_data = { | ||
'user_fullname': user_dict.get('fullname'), | ||
'username': user_dict['name'], | ||
'login_link': h.url_for('hdx_user_auth.new_login') | ||
} | ||
try: | ||
hdx_mailer.mail_recipient([{'email': user_dict['email']}], subject, email_data, footer=user_dict['email'], | ||
snippet='email/content/onboarding/email_username_confirmation.html') | ||
return True | ||
except Exception as e: | ||
error_summary = str(e) | ||
log.error(error_summary) | ||
return False |
This file contains 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