From 6fc2ac7664198e4bae18039ed2f6144d58c2083c Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 13 Feb 2012 03:53:18 +0530 Subject: [PATCH] erang changes - box title, insert images --- itf/emailer/models.py | 8 +++++--- itf/emailer/templatetags/emailer.py | 15 +++++++++++--- itf/templates/emailer/email.html | 20 ++++++++++++------- .../modules/emailer/emailerissue.html | 2 +- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/itf/emailer/models.py b/itf/emailer/models.py index 7fca10f..3ead1d9 100755 --- a/itf/emailer/models.py +++ b/itf/emailer/models.py @@ -54,10 +54,10 @@ class EmailerArticle(models.Model): def get_images(self): return self.articleimage_set.all() - def getImageHTML(self, short_name): + def getImageHTML(self, short_name, typ): img = ArticleImage.objects.filter(article=self).filter(short_name=short_name) if len(img) > 0: - return img[0].getHTML() + return img[0].getHTML(typ) else: return '' @@ -73,7 +73,7 @@ class ArticleImage(models.Model): def getThumbPath(self, size): return get_thumbnail(self.image, size).url - def getHTML(self): + def getHTML(self, typ): thumb = self.getThumbPath("x380") caption = self.caption return "" % (caption, thumb,) @@ -82,6 +82,7 @@ class ArticleImage(models.Model): class Weblink(models.Model): url = models.URLField() title = models.CharField(max_length=512) + box_title = models.CharField(max_length=512, blank=True) text = models.TextField(blank=True) issue = models.ForeignKey(EmailerIssue) @@ -92,6 +93,7 @@ class Weblink(models.Model): class BulletinBoardItem(models.Model): issue = models.ForeignKey(EmailerIssue) title = models.CharField(max_length=512) + box_title = models.CharField(max_length=512, blank=True) text = models.TextField() position = models.IntegerField(default=1) diff --git a/itf/emailer/templatetags/emailer.py b/itf/emailer/templatetags/emailer.py index c8d471e..59cd6fe 100644 --- a/itf/emailer/templatetags/emailer.py +++ b/itf/emailer/templatetags/emailer.py @@ -4,13 +4,22 @@ from itf.emailer.models import * register = template.Library() -def insert_images(value, article_id): +def insert_images_mailer(value, article_id): + return insert_images(value, article_id, "mailer") + +def insert_images_web(value, article_id): + return insert_images(value, article_id, "web") + +def insert_images(value, article_id, typ): regex = 'img\:(.*?)\r?\n' article = EmailerArticle.objects.get(id=article_id) matches = re.findall(regex, value) for m in matches: - imgHTML = article.getImageHTML(m) + imgHTML = article.getImageHTML(m.strip(), typ) value = value.replace("img:" + m, imgHTML) return value -register.filter('insert_images', insert_images) + + +register.filter('insert_images_mailer', insert_images_mailer) +register.filter('insert_images_web', insert_images_web) diff --git a/itf/templates/emailer/email.html b/itf/templates/emailer/email.html index 8c71127..14c65b6 100755 --- a/itf/templates/emailer/email.html +++ b/itf/templates/emailer/email.html @@ -38,7 +38,7 @@ - + {% if weblinks %} + {% endif %} + {% if bbitems %} + {% endif %}

Web Links

{% for weblink in weblinks %} @@ -46,6 +46,8 @@ {% endfor %}

More »

Bulletin Board

{% for bbitem in bbitems %} @@ -53,6 +55,7 @@ {% endfor %}

More »

@@ -82,7 +85,7 @@ -

{{ article.text|insert_images:article.id|markdown }}

+

{{ article.text|insert_images_mailer:article.id|markdown }}

@@ -90,9 +93,9 @@ {% endfor %} - + {% if weblinks %} - +

WEB LINKS

{% for weblink in weblinks %} @@ -102,9 +105,12 @@ - - + + + {% endif %} + + {% if bbitems %}

BULLETIN BOARD

@@ -116,7 +122,7 @@ - + {% endif %} diff --git a/itf/templates/modules/emailer/emailerissue.html b/itf/templates/modules/emailer/emailerissue.html index 5adc952..0e96468 100755 --- a/itf/templates/modules/emailer/emailerissue.html +++ b/itf/templates/modules/emailer/emailerissue.html @@ -69,7 +69,7 @@ {% endif %}
{{ article.subtitle }}
-
{{ article.text|insert_images:article.id|markdown }}
+
{{ article.text|insert_images_web:article.id|markdown }}
{{ article.author_bio|markdown }}
{% endfor %}