permission_required('catalogue.change_book')(GalleryView.as_view()),
name="catalogue_book_gallery"),
url(r'^book/(?P<slug>[^/]+)/xml$', 'book_xml', name="catalogue_book_xml"),
+ url(r'^book/dc/(?P<slug>[^/]+)/xml$', 'book_xml_dc', name="catalogue_book_xml_dc"),
url(r'^book/(?P<slug>[^/]+)/txt$', 'book_txt', name="catalogue_book_txt"),
url(r'^book/(?P<slug>[^/]+)/html$', 'book_html', name="catalogue_book_html"),
url(r'^book/(?P<slug>[^/]+)/epub$', 'book_epub', name="catalogue_book_epub"),
})
-@never_cache
-def book_xml(request, slug):
- book = get_object_or_404(Book, slug=slug)
+def serve_xml(request, book, slug):
if not book.accessible(request):
return HttpResponseForbidden("Not authorized.")
xml = book.materialize()
-
response = http.HttpResponse(xml, content_type='application/xml')
response['Content-Disposition'] = 'attachment; filename=%s.xml' % slug
return response
+@never_cache
+def book_xml(request, slug):
+ book = get_object_or_404(Book, slug=slug)
+ return serve_xml(request, book, slug)
+
+
+@never_cache
+def book_xml_dc(request, slug):
+ book = get_object_or_404(Book, dc_slug=slug)
+ return serve_xml(request, book, slug)
+
+
@never_cache
def book_txt(request, slug):
book = get_object_or_404(Book, slug=slug)