Permalink
Browse files

updated testsite to use south

  • Loading branch information...
1 parent 2ae20c6 commit 481fc0fcc9e23af54834b2c0e3b4b63b0c732f50 @sherzberg sherzberg committed Jun 23, 2011
Showing with 16 additions and 11 deletions.
  1. +2 −7 emailer/models.py
  2. +11 −4 emailer/utils/__init__.py
  3. +3 −0 testsite/settings.py
View
@@ -1,9 +1,4 @@
from django.db import models
-
-try:
- from tinymce.models import HTMLField
-except:
- from django.db.models import TextField as HtmlField
import uuid, datetime
@@ -22,7 +17,7 @@ class Meta:
class EmailTemplate(DefaultModel):
name = models.CharField(blank=False, unique=True, max_length=40)
description = models.TextField(blank=True)
- html = HTMLField(blank=False)
+ html = models.TextField(blank=False)
def __unicode__(self):
return str(self.name)
@@ -75,7 +70,7 @@ class EmailBlast(DefaultModel):
from_address = models.EmailField(blank=False)
subject = models.CharField(blank=False, max_length=40)
- html = HTMLField(blank=False)
+ html = models.TextField(blank=False)
class Meta:
ordering = ['date_created']
View
@@ -1,16 +1,23 @@
from django.template import Context, Template
from django.core.mail import EmailMultiAlternatives
+from django.conf import settings
import datetime
-
from html2text import html2text
from emailer.models import Email, EmailBlast
+from urlparse import urljoin
+
def _append_tracking_image(html,tracking_url):
- html = html + '<img src="%s" alt="tracking url" />' %str(tracking_url)
+ html = html + '<img src="%s" alt="tracking url" />' %str(urljoin(settings.SITE_URL,tracking_url))
return html
+
+def _add_tracking_info(html, tracking_id, tracking_png_url):
+ tracking_html = _append_tracking_image(html, tracking_png_url)
+ return tracking_html
+
def _apply_merge_data(html, merge_data):
t = Template(html)
c = Context(merge_data)
@@ -24,7 +31,7 @@ def _build_message(email):
merged_html = _apply_merge_data(email.html,{})
text_content = html2text(merged_html)
- html_content = _append_tracking_image(merged_html, email.get_tracking_png_url())
+ html_content = _add_tracking_info(merged_html, email.id, email.get_tracking_png_url())
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
@@ -51,7 +58,7 @@ def send_raw_email(to_address, from_address, subject, content_html, merge_data={
be able to track emails. Could be for notifications or acknowledgements of events.
'''
email_blast = EmailBlast()
- email_blast.name = subject+ ' '+str(datetime.datetime.today().strftime("%Y-%b-%d"))
+ email_blast.name = subject+ ' '+str(datetime.datetime.today().strftime("%Y-%b-%d-%m"))
email_blast.type = EmailBlast.BLASTTYPE_ONEOFF
email_blast.send_after = datetime.datetime.now()
email_blast.from_address = from_address
View
@@ -2,6 +2,8 @@
import os
+SITE_URL = "http://testsite.com"
+
ROOT_PATH = os.path.dirname(os.path.realpath(__file__))
CURRENT_PATH = os.getcwd()
@@ -91,6 +93,7 @@
#'django.contrib.flatpages',
'tinymce',
'emailer',
+ 'south',
)
#TINYMCE_SPELLCHECKER = False

0 comments on commit 481fc0f

Please sign in to comment.