Use render_template utility so we can test whether or not this email
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 5 Jun 2011 22:35:20 +0000 (17:35 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 5 Jun 2011 22:35:20 +0000 (17:35 -0500)
sends

mediagoblin/auth/lib.py

index dc37c23039a6dc989b038e70feaef5496f654ce5..f40e560f759fe3f19678b223ece4ade391b37905 100644 (file)
@@ -19,7 +19,7 @@ import random
 
 import bcrypt
 
-from mediagoblin.util import send_email
+from mediagoblin.util import send_email, render_template
 from mediagoblin import globals as mgoblin_globals
 
 
@@ -101,9 +101,14 @@ def send_verification_email(user, request):
     - user: a user object
     - request: the request 
     """
-
-    email_template = request.template_env.get_template(
-        'mediagoblin/auth/verification_email.txt')
+    rendered_email = render_template(
+        request, 'mediagoblin/auth/verification_email.txt',
+        {'username': user['username'],
+         'verification_url': EMAIL_VERIFICATION_TEMPLATE.format(
+                host=request.host,
+                uri=request.urlgen('mediagoblin.auth.verify_email'),
+                userid=unicode(user['_id']),
+                verification_key=user['verification_key'])})
 
     # TODO: There is no error handling in place
     send_email(
@@ -115,10 +120,4 @@ def send_verification_email(user, request):
         # specific GNU MediaGoblin instance in the subject line. For 
         # example "GNU MediaGoblin @ Wandborg - [...]".   
         'GNU MediaGoblin - Verify your email!',
-        email_template.render(
-            username=user['username'],
-            verification_url=EMAIL_VERIFICATION_TEMPLATE.format(
-                host=request.host,
-                uri=request.urlgen('mediagoblin.auth.verify_email'),
-                userid=unicode(user['_id']),
-                verification_key=user['verification_key'])))
+        rendered_email)