Mercurial > public > sg101
diff forums/latest.py @ 594:2469d5864249
Include links to video attachments in forum post RSS feeds.
This is for bitbucket issue #9.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 22 May 2012 19:53:39 -0500 |
parents | ee87ea74d46b |
children | f3fded5df64b |
line wrap: on
line diff
--- a/forums/latest.py Sat May 12 15:45:29 2012 -0500 +++ b/forums/latest.py Tue May 22 19:53:39 2012 -0500 @@ -16,10 +16,11 @@ from django.dispatch import receiver from django.utils import simplejson +from django.template.loader import render_to_string import redis from forums.signals import post_content_update, topic_content_update -from forums.models import Forum, Topic, Post +from forums.models import Forum, Topic, Post, Attachment from forums.views.subscriptions import notify_topic_subscribers from forums.tools import auto_favorite, auto_subscribe from core.services import get_redis_connection @@ -90,11 +91,24 @@ Updates the forum feeds we keep in Redis so that our RSS feeds are quick. """ + # get any attachments for the post + + attachments = Attachment.objects.filter(post=post).select_related( + 'embed').order_by('order') + embeds = [item.embed for item in attachments] + if len(embeds) == 0: + content = post.html + else: + content = render_to_string('forums/post_rss.html', { + 'post': post, + 'embeds': embeds, + }) + # serialize post attributes post_content = { 'id': post.id, 'title': post.topic.name, - 'content': post.html, + 'content': content, 'author': post.user.username, 'pubdate': int(time.mktime(post.creation_date.timetuple())), 'forum_name': post.topic.forum.name,