Include link_root in mail templates, and use

Instead of hardcoding www.postgresql.org, include the link_root variable
the same way we do in the global context when rendering pages, and use
that from the mail templates. Makes for a lot smoother workings in test
environments.
This commit is contained in:
Magnus Hagander
2018-06-14 16:30:13 +02:00
parent e695b9909f
commit 01f2dc496b
5 changed files with 9 additions and 5 deletions

View File

@ -9,8 +9,12 @@ from pgweb.util.helpers import template_to_string
import re import re
def send_template_mail(sender, receiver, subject, templatename, templateattr={}, usergenerated=False, cc=None, replyto=None, receivername=None, sendername=None): def send_template_mail(sender, receiver, subject, templatename, templateattr={}, usergenerated=False, cc=None, replyto=None, receivername=None, sendername=None):
d = {
'link_root': settings.SITE_ROOT,
}
d.update(templateattr)
send_simple_mail(sender, receiver, subject, send_simple_mail(sender, receiver, subject,
template_to_string(templatename, templateattr), template_to_string(templatename, d),
usergenerated=usergenerated, cc=cc, replyto=replyto, usergenerated=usergenerated, cc=cc, replyto=replyto,
receivername=receivername, sendername=sendername) receivername=receivername, sendername=sendername)

View File

@ -4,5 +4,5 @@ PostgreSQL community account {{user.username}} to this email address.
To confirm this change of email address, please click the following To confirm this change of email address, please click the following
link: link:
https://www.postgresql.org/account/profile/change_email/{{token.token}}/ {{link_root}}/account/profile/change_email/{{token.token}}/

View File

@ -3,6 +3,6 @@ PostgreSQL community account.
Please go to the following page and choose a new password: Please go to the following page and choose a new password:
https://www.postgresql.org/account/reset/{{uid}}-{{token}}/ {{link_root}}/account/reset/{{uid}}-{{token}}/
Your username, in case you've forgotten, is {{user.username}}. Your username, in case you've forgotten, is {{user.username}}.

View File

@ -3,7 +3,7 @@ PostgreSQL community account.
Please go to the following page and choose a new password: Please go to the following page and choose a new password:
https://www.postgresql.org/account/reset/{{uid}}-{{token}}/ {{link_root}}/account/reset/{{uid}}-{{token}}/
Your username, in case you've forgotten, is {{user.username}}. Your username, in case you've forgotten, is {{user.username}}.

View File

@ -5,4 +5,4 @@ The following items are currently pending moderation:
Moderators; please check and moderate these items as soon as possible! Moderators; please check and moderate these items as soon as possible!
https://www.postgresql.org/admin/pending/ {{link_root}}/admin/pending/