Mercurial > public > sg101
view gpp/forums/feeds.py @ 265:1ba2c6bf6eb7
Closing #98. Animated GIFs were losing their transparency and animated properties when saved as avatars. Reworked the avatar save process to only run the avatar through PIL if it is too big. This preserves the original uploaded file if it is within the desired size settings. This may still mangle big animated gifs. If this becomes a problem, then maybe look into calling the PIL Image.resize() method directly. Moved the PIL image specific functions from bio.forms to a new module: core.image for better reusability in the future.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 24 Sep 2010 02:12:09 +0000 |
parents | 9b63ad1f2ad2 |
children | 2a03c69792d8 |
line wrap: on
line source
"""This file contains the feed class for the forums application.""" from django.contrib.syndication.views import Feed from django.core.exceptions import ObjectDoesNotExist from django.shortcuts import get_object_or_404 from forums.models import Forum from forums.models import Post from core.functions import copyright_str class ForumsFeed(Feed): """The Feed class for a specific forum""" ttl = '720' author_name = 'Brian Neal' author_email = 'admin@surfguitar101.com' def get_object(self, request, forum_slug): # only return public forums if forum_slug: forum = get_object_or_404(Forum, slug=forum_slug) if forum.category.groups.count() > 0: raise ObjectDoesNotExist return forum else: # return None to indicate we want a combined feed return None def title(self, obj): if obj is None: forum_name = 'Combined' else: forum_name = obj.name return 'SurfGuitar101.com %s Forum Feed' % forum_name def link(self, obj): if obj is None: bits = '' else: bits = obj.slug + '/' return '/feeds/forums/' + bits def description(self, obj): if obj is None: return "User posts to SurfGuitar101.com forums." return obj.description def feed_copyright(self): return copyright_str() def items(self, obj): if obj is None: # return a combined feed of public forum threads items = Post.objects.filter( topic__forum__in=Forum.objects.public_forums()) else: items = Post.objects.filter(topic__forum__id=obj.id) return items.order_by('-creation_date').select_related()[:10] def item_title(self, item): return item.topic.name def item_description(self, item): return item.html def item_author_name(self, item): return item.user.username def item_pubdate(self, item): return item.creation_date def item_categories(self, item): return (item.topic.forum.name, )