Include link_root in mail templates, and use
authorMagnus Hagander <magnus@hagander.net>
Thu, 14 Jun 2018 14:30:13 +0000 (16:30 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 14 Jun 2018 14:31:06 +0000 (16:31 +0200)
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.

pgweb/util/misc.py
templates/account/email_change_email.txt
templates/account/new_account_email.txt
templates/account/password_reset_email.txt
templates/core/moderation_report.txt

index 89deb60a6922875284bf9a0aa06fe511eff0d477..364af5f4fc4802b71cc8a0d1eacf07a59836b20f 100644 (file)
@@ -9,8 +9,12 @@ from pgweb.util.helpers import template_to_string
 import re
 
 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,
-                                        template_to_string(templatename, templateattr),
+                                        template_to_string(templatename, d),
                                         usergenerated=usergenerated, cc=cc, replyto=replyto,
                                         receivername=receivername, sendername=sendername)
 
index 75546cb21c363d3e0d4cabba374dd23baddd2f8d..8622c6ab0cf13922e3f0ce2b5112411351dc6d05 100644 (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
 link:
 
-https://www.postgresql.org/account/profile/change_email/{{token.token}}/
+{{link_root}}/account/profile/change_email/{{token.token}}/
 
index 876f530c11e43c116628a1d517f1e3c16f74058f..53d89c145fd8f3d5f0c41bc5159168b02242bc09 100644 (file)
@@ -3,6 +3,6 @@ PostgreSQL community account.
 
 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}}.
index e5ee92f9079ed44a6eb6c26fba569cc6ab6565e4..66650717a42da4443caf8e60213be8e545746478 100644 (file)
@@ -3,7 +3,7 @@ PostgreSQL community account.
 
 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}}.
 
index b80ed3b2ee9559c8ccf6f3af35f2b243cfab9c91..f917155b64236209b4fbd832bceb74865f814700 100644 (file)
@@ -5,4 +5,4 @@ The following items are currently pending moderation:
 
 Moderators; please check and moderate these items as soon as possible!
 
-https://www.postgresql.org/admin/pending/
+{{link_root}}/admin/pending/