skip *_o.jpg when updating covers
[redakcja.git] / apps / catalogue / feeds.py
1 # -*- coding: utf-8 -*-
2 from django.contrib.syndication.views import Feed
3 from django.shortcuts import get_object_or_404
4 from catalogue.models import Book, Chunk
5
6 class PublishTrackFeed(Feed):
7     title = u"Planowane publikacje"
8     link = "/"
9
10     def description(self, obj):
11         tag, published = obj
12         return u"Publikacje, które dotarły co najmniej do etapu: %s" % tag.name
13
14     def get_object(self, request, slug):
15         published = request.GET.get('published')
16         if published is not None:
17             published = published == 'true'
18         return get_object_or_404(Chunk.tag_model, slug=slug), published
19
20     def item_title(self, item):
21         return item.title
22
23     def items(self, obj):
24         tag, published = obj
25         books = Book.objects.filter(public=True, _on_track__gte=tag.ordering
26                 ).order_by('-_on_track', 'title')
27         if published is not None:
28             books = books.filter(_published=published)
29         return books