erang changes - box title, insert images
This commit is contained in:
parent
3cf1cb68f8
commit
6fc2ac7664
|
@ -54,10 +54,10 @@ class EmailerArticle(models.Model):
|
||||||
def get_images(self):
|
def get_images(self):
|
||||||
return self.articleimage_set.all()
|
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)
|
img = ArticleImage.objects.filter(article=self).filter(short_name=short_name)
|
||||||
if len(img) > 0:
|
if len(img) > 0:
|
||||||
return img[0].getHTML()
|
return img[0].getHTML(typ)
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class ArticleImage(models.Model):
|
||||||
def getThumbPath(self, size):
|
def getThumbPath(self, size):
|
||||||
return get_thumbnail(self.image, size).url
|
return get_thumbnail(self.image, size).url
|
||||||
|
|
||||||
def getHTML(self):
|
def getHTML(self, typ):
|
||||||
thumb = self.getThumbPath("x380")
|
thumb = self.getThumbPath("x380")
|
||||||
caption = self.caption
|
caption = self.caption
|
||||||
return "<img title='%s' src='%s' style='display:block;margin:0 auto;border:1px solid #f7c00c;' />" % (caption, thumb,)
|
return "<img title='%s' src='%s' style='display:block;margin:0 auto;border:1px solid #f7c00c;' />" % (caption, thumb,)
|
||||||
|
@ -82,6 +82,7 @@ class ArticleImage(models.Model):
|
||||||
class Weblink(models.Model):
|
class Weblink(models.Model):
|
||||||
url = models.URLField()
|
url = models.URLField()
|
||||||
title = models.CharField(max_length=512)
|
title = models.CharField(max_length=512)
|
||||||
|
box_title = models.CharField(max_length=512, blank=True)
|
||||||
text = models.TextField(blank=True)
|
text = models.TextField(blank=True)
|
||||||
issue = models.ForeignKey(EmailerIssue)
|
issue = models.ForeignKey(EmailerIssue)
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@ class Weblink(models.Model):
|
||||||
class BulletinBoardItem(models.Model):
|
class BulletinBoardItem(models.Model):
|
||||||
issue = models.ForeignKey(EmailerIssue)
|
issue = models.ForeignKey(EmailerIssue)
|
||||||
title = models.CharField(max_length=512)
|
title = models.CharField(max_length=512)
|
||||||
|
box_title = models.CharField(max_length=512, blank=True)
|
||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
position = models.IntegerField(default=1)
|
position = models.IntegerField(default=1)
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,22 @@ from itf.emailer.models import *
|
||||||
|
|
||||||
register = template.Library()
|
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'
|
regex = 'img\:(.*?)\r?\n'
|
||||||
article = EmailerArticle.objects.get(id=article_id)
|
article = EmailerArticle.objects.get(id=article_id)
|
||||||
matches = re.findall(regex, value)
|
matches = re.findall(regex, value)
|
||||||
for m in matches:
|
for m in matches:
|
||||||
imgHTML = article.getImageHTML(m)
|
imgHTML = article.getImageHTML(m.strip(), typ)
|
||||||
value = value.replace("img:" + m, imgHTML)
|
value = value.replace("img:" + m, imgHTML)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
register.filter('insert_images', insert_images)
|
|
||||||
|
|
||||||
|
register.filter('insert_images_mailer', insert_images_mailer)
|
||||||
|
register.filter('insert_images_web', insert_images_web)
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
<table width="600" border="0" cellspacing="12" cellpadding="1">
|
<table width="600" border="0" cellspacing="12" cellpadding="1">
|
||||||
<tr style="vertical-align:top;">
|
<tr style="vertical-align:top;">
|
||||||
|
{% if weblinks %}
|
||||||
<td style="width:250px; background-color:#f7bd00; color:#fff; padding:10px;">
|
<td style="width:250px; background-color:#f7bd00; color:#fff; padding:10px;">
|
||||||
<p style="font-size:16px; text-align:center; text-transform:uppercase; font-family:'Century Gothic', Arial, Helvetica, sans-serif;">Web Links</p>
|
<p style="font-size:16px; text-align:center; text-transform:uppercase; font-family:'Century Gothic', Arial, Helvetica, sans-serif;">Web Links</p>
|
||||||
{% for weblink in weblinks %}
|
{% for weblink in weblinks %}
|
||||||
|
@ -46,6 +46,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p style="text-align:right;"><a href="#weblinks" style="color:#fff; text-decoration:none; font-size:12px;">More »</a></p>
|
<p style="text-align:right;"><a href="#weblinks" style="color:#fff; text-decoration:none; font-size:12px;">More »</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
{% if bbitems %}
|
||||||
<td style="width:250px; background-color:#f7bd00; color:#fff; padding:10px;">
|
<td style="width:250px; background-color:#f7bd00; color:#fff; padding:10px;">
|
||||||
<p style="font-size:16px; text-align:center; text-transform:uppercase; font-family:'Century Gothic', Arial, Helvetica, sans-serif;">Bulletin Board</p>
|
<p style="font-size:16px; text-align:center; text-transform:uppercase; font-family:'Century Gothic', Arial, Helvetica, sans-serif;">Bulletin Board</p>
|
||||||
{% for bbitem in bbitems %}
|
{% for bbitem in bbitems %}
|
||||||
|
@ -53,6 +55,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p style="text-align:right;"><a href="#bbitems" style="color:#fff; text-decoration:none; font-size:12px;">More »</a></p>
|
<p style="text-align:right;"><a href="#bbitems" style="color:#fff; text-decoration:none; font-size:12px;">More »</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -82,7 +85,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:580px; padding:10px 16px; color:#888; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height:17px;">
|
<td style="width:580px; padding:10px 16px; color:#888; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height:17px;">
|
||||||
|
|
||||||
<p>{{ article.text|insert_images:article.id|markdown }}</p></td>
|
<p>{{ article.text|insert_images_mailer:article.id|markdown }}</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:580px; padding: 10px 16px; color:#888; font-family: Arial, Helvetica, sans-serif; font-size:12px; font-style:italic;">
|
<td style="width:580px; padding: 10px 16px; color:#888; font-family: Arial, Helvetica, sans-serif; font-size:12px; font-style:italic;">
|
||||||
|
@ -90,9 +93,9 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if weblinks %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td style="width:580px; margin:10px 0 10px 0;">
|
<td style="width:580px; margin:10px 0 10px 0;">
|
||||||
<p style="padding:8px; margin-left:10px; background-color:#f7bd00; color:#fff; font-size:24px; font-family:'Century Gothic', Arial, Helvetica, sans-serif;"><a name="weblinks"></a>WEB LINKS</p>
|
<p style="padding:8px; margin-left:10px; background-color:#f7bd00; color:#fff; font-size:24px; font-family:'Century Gothic', Arial, Helvetica, sans-serif;"><a name="weblinks"></a>WEB LINKS</p>
|
||||||
{% for weblink in weblinks %}
|
{% for weblink in weblinks %}
|
||||||
|
@ -102,9 +105,12 @@
|
||||||
|
|
||||||
<!-- <p style="color:#888; font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:8px;">{{ weblinks.text|markdown }}</p> -->
|
<!-- <p style="color:#888; font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:8px;">{{ weblinks.text|markdown }}</p> -->
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if bbitems %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:580px; margin:10px 0 10px 0;">
|
<td style="width:580px; margin:10px 0 10px 0;">
|
||||||
<p style="padding:8px; margin-left:10px; margin-top: 4px;background-color:#f7bd00; color:#fff; font-size:24px; font-family:'Century Gothic', Arial, Helvetica, sans-serif;"><a name="bbitems"></a>BULLETIN BOARD</p>
|
<p style="padding:8px; margin-left:10px; margin-top: 4px;background-color:#f7bd00; color:#fff; font-size:24px; font-family:'Century Gothic', Arial, Helvetica, sans-serif;"><a name="bbitems"></a>BULLETIN BOARD</p>
|
||||||
|
@ -116,7 +122,7 @@
|
||||||
<!-- <p style="color:#888; font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:8px;">{{ bulletinboard.text|markdown }}</p> -->
|
<!-- <p style="color:#888; font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:8px;">{{ bulletinboard.text|markdown }}</p> -->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
</div><!-- ARTICLE IMAGE CLOSING -->
|
</div><!-- ARTICLE IMAGE CLOSING -->
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="articleCaption">{{ article.subtitle }}</div><!-- ARTICLE CAPTION CLOSING -->
|
<div class="articleCaption">{{ article.subtitle }}</div><!-- ARTICLE CAPTION CLOSING -->
|
||||||
<div class="articleText">{{ article.text|insert_images:article.id|markdown }}</div>
|
<div class="articleText">{{ article.text|insert_images_web:article.id|markdown }}</div>
|
||||||
<div class="authorBio">{{ article.author_bio|markdown }}</div>
|
<div class="authorBio">{{ article.author_bio|markdown }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div><!-- ARTICLE EMAILER CLOSING -->
|
</div><!-- ARTICLE EMAILER CLOSING -->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user