Cleaning up emailed stories.

This commit is contained in:
Samuel Clay 2011-05-08 20:21:09 -04:00
parent ff09a6f262
commit 0b4527c3f0
5 changed files with 10 additions and 8 deletions

View file

@ -1,6 +1,5 @@
import datetime
import time
import re
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
@ -987,7 +986,9 @@ def send_story_email(request):
text = render_to_string('mail/email_story_text.xhtml', locals())
html = render_to_string('mail/email_story_html.xhtml', locals())
subject = "%s is sharing a story with you: \"%s\"" % (from_name, story['story_title'])
msg = EmailMultiAlternatives(subject, text, from_email, [to_address])
msg = EmailMultiAlternatives(subject, text, from_email, [to_address],
cc=['%s <%s>' % (from_name, from_email)],
headers={'Reply-To': '%s <%s>' % (from_name, from_email)})
msg.attach_alternative(html, "text/html")
msg.send()

View file

@ -690,7 +690,7 @@ class Feed(models.Model):
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(story['story_content'])
text = ''.join(soup.findAll(text=True))
text = re.sub(r'\n+', '\n', text)
text = re.sub(r'\n+', '\n\n', text)
text = re.sub(r'\t+', '\t', text)
story['text'] = text

View file

@ -1,8 +1,8 @@
<p>{{ from_name }} is sharing a story with you entitled "{{ story.story_title }}". This story is from {{ feed.feed_title }}.</p>
<p>Hello there! {{ from_name }} is sharing a story with you entitled "{{ story.story_title }}" from {{ feed.feed_title }}.</p>
{% if comments %}
<p>{{ from_name }} writes:<br />
"{{ comments }}"</p>
{{ comments }}</p>
{% endif %}
<p>--</p>

View file

@ -1,10 +1,9 @@
{{ from_name }} is sharing a story with you entitled "{{ story.story_title }}". This story is from {{ feed.feed_title }}.
Hello there! {{ from_name }} is sharing a story with you entitled "{{ story.story_title }}" from {{ feed.feed_title }}.
{% if comments %}
{{ from_name }} writes:
"{{ comments }}"
{% endif %}
--
{{ story.story_title }}

View file

@ -2,7 +2,9 @@ from boto.s3.connection import S3Connection
from boto.s3.key import Key
import os
import sys
sys.path.append("/home/conesus/newsblur")
if '/home/sclay/newsblur' not in ' '.join(sys.path):
sys.path.append("/home/sclay/newsblur")
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.conf import settings