X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/8132fc186eb0c5fd02c86828c3a4735754296d02..5913c54d19b8f6775633176032161d49f9b2f1aa:/src/catalogue/feeds.py?ds=sidebyside diff --git a/src/catalogue/feeds.py b/src/catalogue/feeds.py new file mode 100644 index 00000000..4884a4cd --- /dev/null +++ b/src/catalogue/feeds.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from django.contrib.syndication.views import Feed +from django.shortcuts import get_object_or_404 +from catalogue.models import Book, Chunk + +class PublishTrackFeed(Feed): + title = u"Planowane publikacje" + link = "/" + + def description(self, obj): + tag, published = obj + return u"Publikacje, które dotarły co najmniej do etapu: %s" % tag.name + + def get_object(self, request, slug): + published = request.GET.get('published') + if published is not None: + published = published == 'true' + return get_object_or_404(Chunk.tag_model, slug=slug), published + + def item_title(self, item): + return item.title + + def items(self, obj): + tag, published = obj + books = Book.objects.filter(public=True, _on_track__gte=tag.ordering + ).order_by('-_on_track', 'title') + if published is not None: + books = books.filter(_published=published) + return books