fix/refactor refresh covers
[redakcja.git] / apps / catalogue / views.py
index 22aeffe..e71b349 100644 (file)
@@ -204,18 +204,27 @@ def upload(request):
     })
 
 
     })
 
 
-@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()
     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
 
 
     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)
 @never_cache
 def book_txt(request, slug):
     book = get_object_or_404(Book, slug=slug)
@@ -587,8 +596,6 @@ def publish_image(request, slug):
 class GalleryView(UploadView):
     def get_object(self, request, slug):
         book = get_object_or_404(Book, slug=slug)
 class GalleryView(UploadView):
     def get_object(self, request, slug):
         book = get_object_or_404(Book, slug=slug)
-        if not book.public and not request.user.has_perm('catalogue.change_book'):
-            return HttpResponseForbidden()
         if not book.gallery:
             raise Http404
         return book
         if not book.gallery:
             raise Http404
         return book