# HG changeset patch # User Brian Neal # Date 1337734419 18000 # Node ID 2469d5864249392afc58261b84d6677aca896a05 # Parent 302db5b46ec901c8c5212e2692ac61199dae1706 Include links to video attachments in forum post RSS feeds. This is for bitbucket issue #9. diff -r 302db5b46ec9 -r 2469d5864249 forums/latest.py --- 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, diff -r 302db5b46ec9 -r 2469d5864249 sg101/templates/forums/post_rss.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sg101/templates/forums/post_rss.html Tue May 22 19:53:39 2012 -0500 @@ -0,0 +1,8 @@ +{{ post.html|safe }} +
+

Video attachments:

+
    +{% for embed in embeds %} +
  1. {{ embed.title }}
  2. +{% endfor %} +