temporary attributes for bible tags
[redakcja.git] / src / cover / views.py
index 39b12f9..302f5f5 100644 (file)
@@ -65,7 +65,11 @@ def preview(request, book, chunk=None, rev=None):
 
     cover_class = request.GET.get('cover_class', 'default')
 
 
     cover_class = request.GET.get('cover_class', 'default')
 
-    cover = make_cover(info, cover_class=cover_class, width=width, height=height)
+    kwargs = {}
+    if chunk.book.project is not None:
+        if chunk.book.project.logo_mono or chunk.book.project.logo:
+            kwargs['cover_logo'] = (chunk.book.project.logo_mono or chunk.book.project.logo).path
+    cover = make_cover(info, cover_class=cover_class, width=width, height=height, **kwargs)
     response = HttpResponse(content_type=cover.mime_type())
     img = cover.final_image()
     img.save(response, cover.format)
     response = HttpResponse(content_type=cover.mime_type())
     img = cover.final_image()
     img.save(response, cover.format)
@@ -146,9 +150,14 @@ def image_file(request, pk):
 
 @active_tab('cover')
 def image_list(request):
 
 @active_tab('cover')
 def image_list(request):
+    qs = Image.objects.all().order_by('-id')
+    only_unused = request.GET.get('unused')
+    if only_unused:
+        qs = qs.filter(book=None)
     return render(request, "cover/image_list.html", {
     return render(request, "cover/image_list.html", {
-        'object_list': Image.objects.all().order_by('-id'),
+        'object_list': qs,
         'can_add': request.user.has_perm('cover.add_image'),
         'can_add': request.user.has_perm('cover.add_image'),
+        'only_unused': only_unused,
     })
 
 
     })