Generated: Wed 2013-03-13 10:33 CET
Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/utils/mail.py
Stats: 0 executed, 15 missed, 6 excluded, 23 ignored
# -*- coding: utf-8 -*-from django.core.mail import EmailMultiAlternativesfrom django.core.urlresolvers import reversefrom django.template.loader import render_to_stringfrom django.utils.translation import ugettext_lazy as _from django.contrib.sites.models import Sitefrom cms.utils.urlutils import urljoindef send_mail(subject, txt_template, to, context=None, html_template=None, fail_silently=True): """ Multipart message helper with template rendering. """ site = Site.objects.get_current() context = context or {} context.update({ 'login_url': "http://%s" % urljoin(site.domain, reverse('admin:index')), 'title': subject, }) txt_body = render_to_string(txt_template, context) message = EmailMultiAlternatives(subject=subject, body=txt_body, to=to) if html_template: body = render_to_string(html_template, context) message.attach_alternative(body, 'text/html') message.send(fail_silently=fail_silently)def mail_page_user_change(user, created=False, password=""): """ Send email notification to given user. Used it PageUser profile creation/update. """ if created: subject = _('CMS - your user account was created.') else: subject = _('CMS - your user account was changed.') send_mail(subject, 'admin/cms/mail/page_user_change.txt', [user.email], { 'user': user, 'password': password or "*" * 8, 'created': created, }, 'admin/cms/mail/page_user_change.html')