~panosl/django-logos/trunk

« back to all changes in this revision

Viewing changes to logos/feeds.py

  • Committer: Panos Laganakos
  • Date: 2011-11-17 10:57:19 UTC
  • Revision ID: panos.laganakos@gmail.com-20111117105719-b2x4lct123zovedp
fixed slug generation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from logos.conf import settings
5
5
from logos.models import Post
6
6
if settings.USE_TAGS:
7
 
        from tagging.models import Tag, TaggedItem
 
7
        from logos.models import PostTag
8
8
 
9
9
 
10
10
class LatestPosts(Feed):
15
15
        def items(self):
16
16
                return Post.published.all()[:5]
17
17
 
 
18
 
18
19
if settings.USE_TAGS:
19
20
        class TagFeed(Feed):
20
21
                def get_object(self, bits):
21
22
                        if len(bits) != 1:
22
23
                                raise ObjectDoesNotExist
23
 
                        return Tag.objects.get(name__exact=bits[0])
 
24
                        return PostTag.objects.get(slug__exact=bits[0])
24
25
 
25
26
                def title(self, obj):
26
27
                        return '%s feed for "%s" tag' % (Site.objects.get(pk=1).name, obj.name)
31
32
                        return '/blog/tag/%s' % (obj.name,)
32
33
                
33
34
                def items(self, obj):
34
 
                        return TaggedItem.objects.get_by_model(Post, obj.name)
 
35
                        return Post.objects.filter(tags__name__in=[obj.name])