isbn getter
authorJan Szejko <janek37@gmail.com>
Thu, 29 Jun 2017 09:52:26 +0000 (11:52 +0200)
committerJan Szejko <janek37@gmail.com>
Thu, 29 Jun 2017 09:52:26 +0000 (11:52 +0200)
src/catalogue/urls.py
src/catalogue/views.py

index 5f6f8e5..fb6a7b4 100644 (file)
@@ -82,6 +82,7 @@ urlpatterns += patterns(
         'book_fragments', name='book_fragments'),
 
     url(r'^okladka-ridero/(?P<slug>%s).png$' % SLUG, 'ridero_cover'),
+    url(r'^isbn/(?P<book_format>(pdf|epub|mobi|txt|html))/(?P<slug>%s)/' % SLUG, 'get_isbn'),
 
     # Includes.
     url(r'^b/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', 'book_mini', name='catalogue_book_mini'),
index 503b6f5..fd98dee 100644 (file)
@@ -794,3 +794,8 @@ def ridero_cover(request, slug):
     response = HttpResponse(content_type="image/png")
     cover.save(response)
     return response
+
+
+def get_isbn(request, book_format, slug):
+    book = Book.objects.get(slug=slug)
+    return HttpResponse(book.extra_info.get('isbn_%s' % book_format))