Loading opds_catalog/__pycache__/feeds.cpython-35.pyc +483 B (38.8 KiB) File changed.No diff preview for this file type. View original file View changed file opds_catalog/feeds.py +24 −17 Original line number Diff line number Diff line Loading @@ -112,18 +112,18 @@ class opdsFeed(Atom1Feed): if item.get("authors") is not None: for a in item["authors"]: handler.startElement("author", {}) handler.addQuickElement("name", "%s %s"%(a.last_name,a.first_name)) handler.addQuickElement("name", "%s %s"%(a['last_name'],a['first_name'])) #handler.addQuickElement("uri", item['author_link']) handler.endElement("author") handler.addQuickElement("link", "", {"href": reverse("opds_catalog:searchbooks", kwargs={"searchtype":'a', "searchterms":a.id}), handler.addQuickElement("link", "", {"href": reverse("opds_catalog:searchbooks", kwargs={"searchtype":'a', "searchterms":a['id']}), "rel": "related", "type":"application/atom+xml;profile=opds-catalog", "title":_("All books by %(last_name)s %(first_name)s")%{"last_name":a.last_name,"first_name":a.first_name}}) "title":_("All books by %(last_name)s %(first_name)s")%{"last_name":a['last_name'],"first_name":a['first_name']}}) handler.characters("\n") if item.get("genres") is not None: for g in item["genres"]: handler.addQuickElement("category", "", {"term": g.subsection, "label": g.subsection}) handler.addQuickElement("category", "", {"term": g['subsection'], "label": g['subsection']}) handler.characters("\n") class MainFeed(AuthFeed): Loading Loading @@ -383,10 +383,10 @@ class SearchBooksFeed(AuthFeed): else: books={} # Сортируем books = books.order_by('title') books = books.prefetch_related('authors','genres','series').order_by('title','authors') # Фильтруем дубликаты #books_without_double = books.annotate() books = books.values() return {"books":books, "searchterms":searchterms, "searchterms0":searchterms0, "searchtype":searchtype, "page":page} Loading Loading @@ -421,7 +421,7 @@ class SearchBooksFeed(AuthFeed): } def items(self, obj): books_list = obj["books"].order_by("title") books_list = obj["books"] paginator = Paginator(books_list,settings.MAXITEMS) try: Loading @@ -432,27 +432,34 @@ class SearchBooksFeed(AuthFeed): return page def item_title(self, item): return item.title return item['title'] def item_guid(self, item): return "b:%s"%(item.id) return "b:%s"%(item['id']) def item_link(self, item): return reverse("opds_catalog:download", kwargs={"book_id":item.id,"zip":0}) return reverse("opds_catalog:download", kwargs={"book_id":item['id'],"zip":0}) def item_updateddate(self, item): return item.registerdate return item['registerdate'] def item_enclosures(self, item): return ( opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item.id,"zip":0}),"application/fb2" ,"http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item.id,"zip":1}),"application/fb2+zip", "http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:cover", kwargs={"book_id":item.id}),"image/jpeg", "http://opds-spec.org/image"), opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item['id'],"zip":0}),"application/fb2" ,"http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item['id'],"zip":1}),"application/fb2+zip", "http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:cover", kwargs={"book_id":item['id']}),"image/jpeg", "http://opds-spec.org/image"), ) def item_extra_kwargs(self, item): return {'authors':item.authors.all(), 'genres':item.genres.all()} return {'authors':Author.objects.filter(book=item['id']).values(), 'genres':Genre.objects.filter(book=item['id']).values()} def get_context_data(self, **kwargs): context = super(SearchBooksFeed, self).get_context_data(**kwargs) context['authors'] = Author.objects.filter(book=context['obj']['id']).values() context['genres'] = Genre.objects.filter(book=context['obj']['id']).values() context['series'] = Series.objects.filter(book=context['obj']['id']).values() return context class SelectSeriesFeed(AuthFeed): feed_type = opdsFeed Loading opds_catalog/templates/book_description.html +3 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,9 @@ {{ obj.cat_name }} {% else %} <b>{% trans "Book name:" %} </b>{{ obj.title }}<br/> <b>{% trans "Authors:" %} </b>{% for a in obj.authors.all %}<author><name>{{ a.last_name }} {{ a.first_name }}</name></author>{% endfor %}<br/> <b>{% trans "Genres:" %} </b>{% for g in obj.genres.all %}<category term="{{ g.subsection }}" label="{{ g.subsection }}" />{% endfor %}<br/> <b>{% trans "Authors:" %} </b>{% for a in authors %}{{ a.last_name }} {{ a.first_name }}; {% endfor %}<br/> <b>{% trans "Genres:" %} </b>{% for g in genres %}{{ g.subsection }}; {% endfor %}<br/> <b>{% trans "Series:" %} </b>{% for s in series %}{{s.ser}}; {% endfor %}<br/> <b>{% trans "File:" %} </b>{{ obj.filename }}<br/> <b>{% trans "File size:" %} </b>{{ obj.filesize }}<br/> <b>{% trans "Changes date:" %} </b>{{ obj.docdate }}<br/> Loading Loading
opds_catalog/__pycache__/feeds.cpython-35.pyc +483 B (38.8 KiB) File changed.No diff preview for this file type. View original file View changed file
opds_catalog/feeds.py +24 −17 Original line number Diff line number Diff line Loading @@ -112,18 +112,18 @@ class opdsFeed(Atom1Feed): if item.get("authors") is not None: for a in item["authors"]: handler.startElement("author", {}) handler.addQuickElement("name", "%s %s"%(a.last_name,a.first_name)) handler.addQuickElement("name", "%s %s"%(a['last_name'],a['first_name'])) #handler.addQuickElement("uri", item['author_link']) handler.endElement("author") handler.addQuickElement("link", "", {"href": reverse("opds_catalog:searchbooks", kwargs={"searchtype":'a', "searchterms":a.id}), handler.addQuickElement("link", "", {"href": reverse("opds_catalog:searchbooks", kwargs={"searchtype":'a', "searchterms":a['id']}), "rel": "related", "type":"application/atom+xml;profile=opds-catalog", "title":_("All books by %(last_name)s %(first_name)s")%{"last_name":a.last_name,"first_name":a.first_name}}) "title":_("All books by %(last_name)s %(first_name)s")%{"last_name":a['last_name'],"first_name":a['first_name']}}) handler.characters("\n") if item.get("genres") is not None: for g in item["genres"]: handler.addQuickElement("category", "", {"term": g.subsection, "label": g.subsection}) handler.addQuickElement("category", "", {"term": g['subsection'], "label": g['subsection']}) handler.characters("\n") class MainFeed(AuthFeed): Loading Loading @@ -383,10 +383,10 @@ class SearchBooksFeed(AuthFeed): else: books={} # Сортируем books = books.order_by('title') books = books.prefetch_related('authors','genres','series').order_by('title','authors') # Фильтруем дубликаты #books_without_double = books.annotate() books = books.values() return {"books":books, "searchterms":searchterms, "searchterms0":searchterms0, "searchtype":searchtype, "page":page} Loading Loading @@ -421,7 +421,7 @@ class SearchBooksFeed(AuthFeed): } def items(self, obj): books_list = obj["books"].order_by("title") books_list = obj["books"] paginator = Paginator(books_list,settings.MAXITEMS) try: Loading @@ -432,27 +432,34 @@ class SearchBooksFeed(AuthFeed): return page def item_title(self, item): return item.title return item['title'] def item_guid(self, item): return "b:%s"%(item.id) return "b:%s"%(item['id']) def item_link(self, item): return reverse("opds_catalog:download", kwargs={"book_id":item.id,"zip":0}) return reverse("opds_catalog:download", kwargs={"book_id":item['id'],"zip":0}) def item_updateddate(self, item): return item.registerdate return item['registerdate'] def item_enclosures(self, item): return ( opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item.id,"zip":0}),"application/fb2" ,"http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item.id,"zip":1}),"application/fb2+zip", "http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:cover", kwargs={"book_id":item.id}),"image/jpeg", "http://opds-spec.org/image"), opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item['id'],"zip":0}),"application/fb2" ,"http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:download", kwargs={"book_id":item['id'],"zip":1}),"application/fb2+zip", "http://opds-spec.org/acquisition/open-access"), opdsEnclosure(reverse("opds_catalog:cover", kwargs={"book_id":item['id']}),"image/jpeg", "http://opds-spec.org/image"), ) def item_extra_kwargs(self, item): return {'authors':item.authors.all(), 'genres':item.genres.all()} return {'authors':Author.objects.filter(book=item['id']).values(), 'genres':Genre.objects.filter(book=item['id']).values()} def get_context_data(self, **kwargs): context = super(SearchBooksFeed, self).get_context_data(**kwargs) context['authors'] = Author.objects.filter(book=context['obj']['id']).values() context['genres'] = Genre.objects.filter(book=context['obj']['id']).values() context['series'] = Series.objects.filter(book=context['obj']['id']).values() return context class SelectSeriesFeed(AuthFeed): feed_type = opdsFeed Loading
opds_catalog/templates/book_description.html +3 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,9 @@ {{ obj.cat_name }} {% else %} <b>{% trans "Book name:" %} </b>{{ obj.title }}<br/> <b>{% trans "Authors:" %} </b>{% for a in obj.authors.all %}<author><name>{{ a.last_name }} {{ a.first_name }}</name></author>{% endfor %}<br/> <b>{% trans "Genres:" %} </b>{% for g in obj.genres.all %}<category term="{{ g.subsection }}" label="{{ g.subsection }}" />{% endfor %}<br/> <b>{% trans "Authors:" %} </b>{% for a in authors %}{{ a.last_name }} {{ a.first_name }}; {% endfor %}<br/> <b>{% trans "Genres:" %} </b>{% for g in genres %}{{ g.subsection }}; {% endfor %}<br/> <b>{% trans "Series:" %} </b>{% for s in series %}{{s.ser}}; {% endfor %}<br/> <b>{% trans "File:" %} </b>{{ obj.filename }}<br/> <b>{% trans "File size:" %} </b>{{ obj.filesize }}<br/> <b>{% trans "Changes date:" %} </b>{{ obj.docdate }}<br/> Loading