Skip to content

Commit 83ddf1f

Browse files
committed
Fixed #19. Used configuration option for public url instead of using url_for function.
1 parent 516d39e commit 83ddf1f

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

users/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from users.config import (
1414
PROJECT_NAME,
15+
PUBLIC_URL,
1516
PROJECT_FAVICON_FILE,
1617
MAIL_CONFIG,
1718
SQLITE_DB_PATH,
@@ -94,6 +95,7 @@ def setup_logger():
9495

9596
# Load configuration
9697
APP.config['PROJECT_NAME'] = PROJECT_NAME
98+
APP.config['PUBLIC_URL'] = PUBLIC_URL
9799
APP.config['PROJECT_FAVICON_FILE'] = PROJECT_FAVICON_FILE
98100
APP.config.update(MAIL_CONFIG)
99101
mail = Mail(APP)

users/config.py.prod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import os
66
# It would override page title, email confirmation to user, so on.
77
PROJECT_NAME = 'InaSAFE'
88

9+
# PUBLIC_URL: Public URL that is used for publishing this apps.
10+
# It will be used for detail of the email confirmation, and other things if
11+
# it's needed
12+
PUBLIC_URL = 'http://users.inasafe.org'
13+
914
# PROJECT_FAVICON_FILE: Path to project favicon file
1015
PROJECT_FAVICON_FILE = '/users/static/img/user-icon.png'
1116

users/config.py.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import os
66
# It would override page title, email confirmation to user, so on.
77
PROJECT_NAME = 'InaSAFE'
88

9+
# PUBLIC_URL: Public URL that is used for publishing this apps.
10+
# It will be used for detail of the email confirmation, and other things if
11+
# it's needed
12+
PUBLIC_URL = 'http://users.inasafe.org'
13+
14+
915
# PROJECT_FAVICON_FILE: Path to project favicon file
1016
PROJECT_FAVICON_FILE = '/users/static/img/user-icon.png'
1117

users/templates/text/registration_confirmation_email.txt

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

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

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

users/views.py

Lines changed: 4 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, url_for
8+
from flask import render_template, Response, request
99
from werkzeug.exceptions import default_exceptions
1010

1111
# App declared directly in __init__ as per
@@ -167,7 +167,7 @@ def add_user_view():
167167
body = render_template(
168168
'text/registration_confirmation_email.txt',
169169
project_name=APP.config['PROJECT_NAME'],
170-
url=url_for('map_view', _external=True),
170+
url=APP.config['PUBLIC_URL'],
171171
user=added_user)
172172
recipient = added_user['email']
173173
send_async_mail(
@@ -330,7 +330,7 @@ def delete_user_view(guid):
330330
"""
331331
# Delete User
332332
delete_user(guid)
333-
return url_for('map_view')
333+
return APP.config['PUBLIC_URL']
334334

335335

336336
@APP.route('/download')
@@ -388,7 +388,7 @@ def reminder_view():
388388
body = render_template(
389389
'text/registration_confirmation_email.txt',
390390
project_name=APP.config['PROJECT_NAME'],
391-
url=url_for('map_view', _external=True),
391+
url=APP.config['PUBLIC_URL'],
392392
user=user)
393393
send_async_mail(
394394
sender=MAIL_ADMIN,

0 commit comments

Comments
 (0)