fix stats api
[redakcja.git] / src / documents / models / listeners.py
index d306e4e..1a022fb 100644 (file)
@@ -3,6 +3,7 @@
 #
 from django.contrib.auth.models import User
 from django.db import models
+import cover.models
 from documents.models import (Book, Chunk, Image, BookPublishRecord,
         ImagePublishRecord)
 from documents.signals import post_publish
@@ -53,3 +54,9 @@ def listener_create(sender, instance, created, **kwargs):
         instance.chunk_set.create(number=1, slug='1')
 models.signals.post_save.connect(listener_create, sender=Book)
 
+
+def cover_changed(sender, instance, created, **kwargs):
+    for book in instance.book_set.all():
+        book.build_cover()
+models.signals.post_save.connect(cover_changed, sender=cover.models.Image)
+