Skip to content

Commit 663d909

Browse files
committed
use url_for instead of hardcoded PUBLIC_URL to generate links for email
1 parent a0594a3 commit 663d909

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

users/templates/text/registration_confirmation_email.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ to the centre of your nearest town / state or province or country).
1717

1818
Deleting or editing your user record does not require a user name or password, only that
1919
you click on this unique (for your user record) link below:
20-
- Link: {{ url }}/edit/{{ user.guid }}
20+
- Link: {{ edit_url }}
2121

2222
If you have ever forget your special link above, you can request this message to be
2323
resent to you by using the 'I forgot my edit link' menu on {{ url }}.

users/views.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
import json
77

8-
from flask import render_template, Response, request
8+
from flask import render_template, Response, request, url_for
99
from werkzeug.exceptions import default_exceptions
1010

1111
# App declared directly in __init__ as per
@@ -153,7 +153,9 @@ def add_user_view():
153153
body = render_template(
154154
'text/registration_confirmation_email.txt',
155155
project_name=APP.config['PROJECT_NAME'],
156-
url=APP.config['PUBLIC_URL'],
156+
url=url_for(".map_view", _external=True),
157+
edit_url=url_for(".edit_user_view", guid=added_user["guid"],
158+
_external=True),
157159
user=added_user)
158160
recipient = added_user['email']
159161
send_async_mail(
@@ -307,7 +309,7 @@ def delete_user_view(guid):
307309
"""
308310
# Delete User
309311
delete_user(guid)
310-
return APP.config['PUBLIC_URL']
312+
return url_for(".map_view")
311313

312314

313315
@APP.route('/download')
@@ -362,7 +364,8 @@ def reminder_view():
362364
body = render_template(
363365
'text/registration_confirmation_email.txt',
364366
project_name=APP.config['PROJECT_NAME'],
365-
url=APP.config['PUBLIC_URL'],
367+
url=url_for(".map_view", _external=True),
368+
edit_url=url_for(".edit_user_view", guid=user["guid"], _external=True),
366369
user=user)
367370
send_async_mail(
368371
sender=MAIL_ADMIN,

0 commit comments

Comments
 (0)