Mercurial > public > sg101
changeset 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 | 302db5b46ec9 |
children | f3fded5df64b |
files | forums/latest.py sg101/templates/forums/post_rss.html |
diffstat | 2 files changed, 24 insertions(+), 2 deletions(-) [+] |
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,
--- /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 }} +<hr /> +<p>Video attachments:</p> +<ol> +{% for embed in embeds %} + <li><a href="{{ embed.url }}">{{ embed.title }}</a></li> +{% endfor %} +</ol>