Commit 17c3c33c authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

branding: Use branding util to render email templates

Use synnefo_branding.util.render_to_string accross synnefo apps to be able to
use branding variables within the templates.
parent 2659eb45
......@@ -54,6 +54,7 @@ from django.core import validators
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import PermissionDenied
from synnefo_branding.utils import render_to_string
from synnefo.lib import join_urls
from astakos.im.models import (
AstakosUser, EmailChange, Invitation,
......@@ -548,7 +549,6 @@ class ExtendedPasswordResetForm(PasswordResetForm):
for user in self.users_cache:
url = user.astakosuser.get_password_reset_url(token_generator)
url = join_urls(BASEURL, url)
t = loader.get_template(email_template_name)
c = {
'email': user.email,
'url': url,
......@@ -557,9 +557,10 @@ class ExtendedPasswordResetForm(PasswordResetForm):
'baseurl': BASEURL,
'support': CONTACT_EMAIL
}
message = render_to_string(email_template_name, c)
from_email = settings.SERVER_EMAIL
send_mail(_(PASSWORD_RESET_EMAIL_SUBJECT),
t.render(Context(c)),
message,
from_email,
[user.email],
connection=get_connection())
......
......@@ -35,7 +35,6 @@ import logging
import socket
from django.utils.translation import ugettext as _
from synnefo_branding.utils import render_to_string
from django.core.mail import send_mail, get_connection
from django.core.urlresolvers import reverse
from django.template import Context, loader
......@@ -47,6 +46,8 @@ from django.core.exceptions import PermissionDenied
from django.db import IntegrityError
from django.http import Http404
from synnefo_branding.utils import render_to_string
from urllib import quote
from smtplib import SMTPException
from datetime import datetime
......@@ -235,13 +236,12 @@ def send_change_email(
ec, request, email_template_name='registration/email_change_email.txt'):
url = ec.get_url()
url = request.build_absolute_uri(url)
t = loader.get_template(email_template_name)
c = {'url': url, 'site_name': SITENAME,
'support': CONTACT_EMAIL, 'ec': ec}
c = {'url': url, 'site_name': SITENAME, 'support': CONTACT_EMAIL,
'ec': ec}
message = render_to_string(email_template_name, c)
from_email = settings.SERVER_EMAIL
send_mail(_(EMAIL_CHANGE_EMAIL_SUBJECT), t.render(Context(c)),
from_email, [ec.new_email_address],
connection=get_connection())
send_mail(_(EMAIL_CHANGE_EMAIL_SUBJECT), message, from_email,
[ec.new_email_address], connection=get_connection())
msg = 'Sent change email for %s' % ec.user.log_display
logger.log(LOGGING_LEVEL, msg)
......
......@@ -39,7 +39,7 @@ from smtplib import SMTPException
from django.conf import settings
from django.core.mail import send_mail, get_connection
from django.utils.translation import ugettext as _
from django.template.loader import render_to_string
from synnefo_branding.utils import render_to_string
import astakos.im.messages as astakos_messages
......
......@@ -40,7 +40,7 @@ from django.core.urlresolvers import resolve
from django.conf import settings
from django.template import TemplateSyntaxError, Variable
from django.utils.translation import ugettext as _
from django.template.loader import render_to_string
from synnefo_branding.utils import render_to_string
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
......
......@@ -65,13 +65,14 @@ from django.views.generic.create_update import (
from django.views.generic.list_detail import object_list, object_detail
from django.core.xheaders import populate_xheaders
from django.core.exceptions import ValidationError, PermissionDenied
from django.template.loader import render_to_string
from django.views.decorators.http import require_http_methods
from django.db.models import Q
from django.core.exceptions import PermissionDenied
from django.utils import simplejson as json
from django.contrib.auth.views import redirect_to_login
from synnefo_branding.utils import render_to_string
import astakos.im.messages as astakos_messages
from astakos.im import activation_backends
......
......@@ -36,7 +36,7 @@ import recaptcha.client.captcha as captcha
from django import forms
from django.utils.safestring import mark_safe
from django.utils import simplejson as json
from django.template.loader import render_to_string
from synnefo_branding.utils import render_to_string
from astakos.im.settings import RECAPTCHA_PUBLIC_KEY, RECAPTCHA_OPTIONS, \
RECAPTCHA_USE_SSL
......
......@@ -40,7 +40,7 @@ from django.template import loader
from django.http import HttpResponse
from django.utils.translation import get_language
from django.utils import simplejson as json
from django.template.loader import render_to_string
from synnefo_branding.utils import render_to_string
from django.core.urlresolvers import reverse
from django.template import RequestContext
from synnefo_branding import settings as snf_settings
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment