def build_email_content(self, contact): """Generate the mail for a contact""" uidb36, token = tokenize(contact) context = Context({'contact': contact, 'domain': Site.objects.get_current().domain, 'newsletter': self.newsletter, 'tracking_image_format': TRACKING_IMAGE_FORMAT, 'uidb36': uidb36, 'token': token}) content = self.newsletter_template.render(context) if TRACKING_LINKS: content = track_links(content, context) link_site = render_to_string('newsletter/newsletter_link_site.html', context) content = body_insertion(content, link_site) if INCLUDE_UNSUBSCRIPTION: unsubscription = render_to_string('newsletter/newsletter_link_unsubscribe.html', context) content = body_insertion(content, unsubscription, end=True) if TRACKING_IMAGE: image_tracking = render_to_string('newsletter/newsletter_image_tracking.html', context) content = body_insertion(content, image_tracking, end=True) return smart_text(content)
def render_newsletter(request, slug, context): """Return a newsletter in HTML format""" newsletter = get_object_or_404(Newsletter, slug=slug) context.update({'newsletter': newsletter, 'domain': Site.objects.get_current().domain}) content = render_string(newsletter.content, context) title = render_string(newsletter.title, context) if TRACKING_LINKS: content = track_links(content, context) unsubscription = render_file('newsletter/newsletter_link_unsubscribe.html', context) content = body_insertion(content, unsubscription, end=True) return render_to_response('newsletter/newsletter_detail.html', {'content': content, 'title': title, 'object': newsletter}, context_instance=RequestContext(request))
def render_newsletter(request, slug, context): """Return a newsletter in HTML format""" newsletter = get_object_or_404(Newsletter, slug=slug) context.update({ 'newsletter': newsletter, 'domain': Site.objects.get_current().domain }) content = render_string(newsletter.content, context) title = render_string(newsletter.title, context) if TRACKING_LINKS: content = track_links(content, context) unsubscription = render_file('newsletter/newsletter_link_unsubscribe.html', context) content = body_insertion(content, unsubscription, end=True) return render_to_response('newsletter/newsletter_detail.html', { 'content': content, 'title': title, 'object': newsletter }, context_instance=RequestContext(request))