book/picture-only tags
[wolnelektury.git] / src / catalogue / models / book.py
index 140ba50..44ee02e 100644 (file)
@@ -195,6 +195,9 @@ class Book(models.Model):
         else:
             return self.media.filter(type=type_).exists()
 
+    def has_audio(self):
+        return self.has_media('mp3')
+
     def get_media(self, type_):
         if self.has_media(type_):
             if type_ in Book.formats:
@@ -388,6 +391,11 @@ class Book(models.Model):
 
         meta_tags = Tag.tags_from_info(book_info)
 
+        for tag in meta_tags:
+            if not tag.for_books:
+                tag.for_books = True
+                tag.save()
+
         book.tags = set(meta_tags + book_shelves)
 
         cover_changed = old_cover != book.cover_info()