def test_track_links(self):
     uidb36, token = tokenize(self.contact)
     context = Context({'contact': "gino",
                        'domain': Site.objects.get_current().domain,
                        'newsletter': self.newsletter,
                        'tracking_image_format': 'jpg',
                        'uidb36': uidb36, 'token': token})
     rendered = track_links(self.text, context)
Beispiel #2
0
 def test_track_links(self):
     uidb36, token = tokenize(self.contact)
     context = Context({
         'contact': "gino",
         'domain': Site.objects.get_current().domain,
         'newsletter': self.newsletter,
         'tracking_image_format': 'jpg',
         'uidb36': uidb36,
         'token': token
     })
     rendered = track_links(self.text, context)
Beispiel #3
0
    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)
Beispiel #4
0
 def test_tokenize_untokenize(self):
     uidb36, token = tokenize(self.contact)
     self.assertEquals(untokenize(uidb36, token), self.contact)
     self.assertRaises(Http404, untokenize, 'toto', token)
     self.assertRaises(Http404, untokenize, uidb36, 'toto')
 def test_tokenize_untokenize(self):
     uidb36, token = tokenize(self.contact)
     self.assertEquals(untokenize(uidb36, token), self.contact)
     self.assertRaises(Http404, untokenize, 'toto', token)
     self.assertRaises(Http404, untokenize, uidb36, 'toto')